Asp.net menyusi tanlangan element

Men ushbu asp.net Menyu boshqaruvi muammosini kunlar davomida kurashyapman va bu meni aqldan ozdirmoqda. Bu erda kod:


    
    
    
    
    
        <div class="dinamicMenuItemTemplate">
            
        </div>
    
    
    
    
        
            <div class="staticMenuItemTemplate">
                <div class="innerMenuElement">
                    </div>
                </div>
        
    

Endi bu mening CSS:

.staticMenuItemTemplate 
{
    background-position: left;
    background-image: url('../../images/mainLayout/menuDefault.png');
    background-repeat: no-repeat;
    width: 100px;
    text-align: center;
    height: 25px;
    position: relative;
    top: 0px;
    left: 0px;
}
.staticMenuItemTemplate:hover
{
    background-image: url('../../images/mainLayout/menuHover.png');
    background-repeat: no-repeat;
    background-position: left;
    font-weight: bold;
}
.staticMenuItemTemplateSelected
{
    background-image: url('../../images/mainLayout/menuSelected.png') !important;
    background-repeat: no-repeat !important;
    background-position: left !important;
    color: #FF00FF !important;
}

staticMenuItemTemplate: hover sinfida ishlayotgan va, albatta, tasvir o'zgartirilsa, menyudagi element tanlangan bo'lsa (menuSelected.png) boshqa tasvirni ko'rsatishni xohlayman, class staticMenuItemTemplateSelected kodi> qilmaydi. Faqat matn pushti bo'ladi, ammo tasvir o'zgarmaydi.

Yordamingiz uchun rahmat.

2
.staticMenuItemTemplateSelected parametrini .staticMenuItemTemplate: faol ga o'zgartirsangiz nima bo'ladi? Yoki ushbu o'zgarishlarni CSS-ning o'zi emas, balki StaticSelectedStyle xususiyatiga kiritganingizda?
qo'shib qo'ydi muallif jwiscarson, manba
Bundan tashqari, bu nusxa ko'chirish/joylashtirish xatosi ekanligiga ishonchim komil emas, lekin siz StaticItemTemplate </div> yorlig'i yetishmayotgandirsiz. Buning sababi sizning muammolaringizning sababini tasavvur qila olmayman, lekin shunga qaramay.
qo'shib qo'ydi muallif jwiscarson, manba
O'zingiz tasodifan, boshqalarning muammosini to'g'ridan-to'g'ri tekshirishi mumkin bo'lgan joyga o'rnashib olasizmi?
qo'shib qo'ydi muallif jwiscarson, manba
staticMenuItemTemplateSelected sinf tanlagan elementingizga (HTML chiqishi manbasini tekshirish) amal qilinishiga ishonchingiz komilmi? Bundan tashqari, tanlangan rasmning shu yo'ldan borligiga ishonchingiz komilmi? Agar siz u manzilni manzil satriga qo'ygan bo'lsangiz brauzerda paydo bo'ladimi?
qo'shib qo'ydi muallif Shawn Steward, manba
Shawn Steward uchun staticMenuItemTemplateSelected sinf qo'llaniladi, chunki shrift rangi qizildan pushtga to'g'ri o'zgaradi va tanlangan rasmlar mening yo'limda mavjud, chunki u brauzerda ko'rinadi. Jwiscarson uchun, men o'zgartirganimda: faol yoki: focus yoki: bog'lanish ishlamadi, chunki tanlangan rasm faqatgina tıklandığında va keyin yo'qolganida paydo bo'ldi. Barcha div'lar to'g'ri yopilgan. Sizning tashvishlaringiz uchun tashakkur.
qo'shib qo'ydi muallif poldoj, manba
StaticSelectedStyle'da shriftni oldindan rangi qizil rangga qo'yib, uni bekor qilsam bo'lmaydimi va aslida pushti rangga aylanadi.
qo'shib qo'ydi muallif poldoj, manba
Afsuski, men sizni ko'rsatadigan hech qanday jonli misolim yo'q, afsus.
qo'shib qo'ydi muallif poldoj, manba

1 javoblar

Menimcha, muammo bu HTML uchun HTMLni qanday bajarishi bilan bog'liq. Mening sinovlarimda quyidagi narsalar bilan yakun topaman:

<td>
  
    <div class="staticMenuItemTemplate">
      Menu text here </div> 
</td>

So you can see that the tag is getting the staticMenuItemTemplateSelected applied, but the inner <div> is getting the staticMenuItemTemplate class which ends up overriding the staticMenuItemTemplateSelected style since it is more specific.

If you change your declaration of .staticMenuItemTemplateSelected to

.staticMenuItemTemplateSelected .staticMenuItemTemplate
{
    background-image: url('../../images/mainLayout/menuSelected.png') !important;
    background-repeat: no-repeat !important;
    background-position: left !important;
    color: #FF00FF !important;
}

you will make that style more specific than the style for .staticMenuItemTemplate and it should work.

FireBug with FireFox is a great tool for investigating CSS weirdness issues.

0
qo'shib qo'ydi
Rahmat sizga juda ko'p csm8118, sizning yechimingiz jozibasi kabi ishladi! RAHMAT
qo'shib qo'ydi muallif poldoj, manba