|
-
[RESOLVED] Two floated divs, if one is empty, hide it, and make the other one width:100%
Hi.
I have the following setup:
Code:
<style type="text/css">
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
body {
font-family:arial;
font-size:12px;
}
.wrapper {
width: 200px;
border:1px solid #000;
}
.one, .two {
float: left;
width: 100px;
height: 100px;
}
.one {background-color: red}
.two {background-color: green}
</style>
and
HTML Code:
<div class="wrapper clearfix">
<div class="one"></div>
<div class="two"></div>
</div>
I would like to check if div two is empty, and if it is, the div one should stretch to full width. How is that possible with jQuery?
-
something like this maybe?
Code:
$('document').ready(function(){
if($('.two').html() == ""){
$('.two').hide();
$('.one').css('width', '200px');
};
});
maybe you want:
Code:
$('.one').css('width', '200px');
to be:
Code:
$('.one').css('width', '100%');
not tested :-)
Last edited by Nomistake; 09-14-2012 at 08:28 AM.
When the only tool you have is a hammer, everything looks like a nail.
-
@Nomistake: It works like a charm. Thanks a lot. :-)
-
When the only tool you have is a hammer, everything looks like a nail.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks