Reputation: 181
I need to select element that I think can be selected with this code:
#main_slider h2 < img#main_slider_menu_image {
background: initial !important;
text-align: left !important;
width: 90% !important;
}
I'm trying to select #main_slider h2 that have image with id #main_slider_menu_image. I really need make it work. But this code is not working now. So have can I write it true to make this work?
Also add full html block:
<div class="main" id="main_slider">
<h2>Фланцевые уплотнения</h2>
<img id="main_slider_menu_image" class="slider_img" src="/upload/iblock/360/ngzzkvgrvbicbboyyo thkgszaddkxcakjzktvq.png">
<p>
Прокладки стальные овального и восьмиугольного сечения, уплотнительные линзы. Прокладки паронитовые, фторопластовые, безасбестовые, прокладки из терморасширенного графита. Прокладки спирально-навитые.
</p>
</div>
Jquery added now as tag, because no way to do it by CSS. Still loking answer. I have selected p by using:
img#main_slider_menu_image ~ p {
}
because p is after img, but I can't select h2 this way because it before img. Image switch classes in slider and I have task to change style of h2, And all I have is only image with different classes. and when list hovered image switch id to main_slider_menu_image . Very difficult task for me, and I son't know the programmer who made this slider... The website is Bitrix website
Upvotes: 1
Views: 367
Reputation: 22158
That's <
doesn't exists in CSS. There will be the opposite:
#main_slider h2 > img#main_slider_menu_image
See more:
https://developer.mozilla.org/es/docs/Web/CSS/Child_selectors
In your case, your solution is the sibling selector
#main_slider h2 + img#main_slider_menu_image
https://developer.mozilla.org/es/docs/Web/CSS/Adjacent_sibling_selectors
Upvotes: 1