We would like to know how to expand content to 100% width if no sidebar content.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.container {<!-- w w w .j a va 2 s . c o m-->
position: relative;
}
.sidebar {
position: absolute;
right: 0;
width: 150px;
}
.sidebar+.content {
margin-right: 150px;
}
.content {
background-color: yellow;
height: 300px;
}
.sidebar {
background-color: blue;
height: 200px;
}
</style>
</head>
<body>
<div class='container'>
<div class='sidebar'></div>
<div class='content'></div>
</div>
<br />
<div class='container'>
<div class='content'></div>
</div>
</body>
</html>
The code above is rendered as follows: