admin管理员组文章数量:1421492
I need to make style changes in a nested div. Code below :
<div id="video_id" class="videoLayout">
<div style="width:695px;height:391px;"></div>
</div>
I want to change style in nested div to width:600px;height:340px;
when device ipad and orientation landscape. (media query / jquery any solution will do)
Anyone has any advise. Thanks
I need to make style changes in a nested div. Code below :
<div id="video_id" class="videoLayout">
<div style="width:695px;height:391px;"></div>
</div>
I want to change style in nested div to width:600px;height:340px;
when device ipad and orientation landscape. (media query / jquery any solution will do)
Anyone has any advise. Thanks
Share Improve this question edited Nov 14, 2013 at 9:32 Pete 58.5k29 gold badges130 silver badges184 bronze badges asked Nov 14, 2013 at 9:28 user2991371user2991371 131 silver badge4 bronze badges 3- ...<div id="video_id" class="videoLayout"> <div style="width:695px;height:391px;"> – user2991371 Commented Nov 14, 2013 at 9:30
- i am not sure how to drill down in 2nd div and change css / style for nested div. There is also lots of code inside 2nd div... but it's not relevent as i want to keep it as it is... just change style in nested div that's inline. – user2991371 Commented Nov 14, 2013 at 9:31
-
this is how to target ipad only and to target the div you want you can use
#video_id > div
– Pete Commented Nov 14, 2013 at 9:35
3 Answers
Reset to default 2There are a few ways to access a nested <div>
. The easiest way is to assign it a class/id and just target it directly! If that isn't an option, there's a few methods in CSS to target a nested element.
DEMO
Selector 1:
#container #nested-div{
}
A space between identifiers (in this case 2 IDs) means the CSS will first find the element with that first ID, then go inside and look at all it's nested (child) elements and their children etc with the second ID.
Selector 2:
#container > div{
}
This does the same thing, but because of the >
between them, the CSS only looks at the direct children, it doesn't go any further down.
iPad Landscape Orientation
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
#video_id > div { width:600px;height:400px;}
}
Check if this jQuery solution will work:
$('div#video_id').find('div:first').attr('style', 'width:600px; height:340px;');
本文标签:
版权声明:本文标题:javascript - Change style of div inside a div. The inside div has inline css without any id and class - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745352530a2654856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论