Fun with CSS floats - css

I have the following CSS for some DIVs,
#wrapper {
width:960px;
border:1px solid red;
overflow:hidden;
}
#maintitle {
width:600px;
height:50px;
float:left;
border:1px solid #333;
}
#sidebar {
clear:both;
float:left;
width:100px;
height:200px;
border:1px solid #ccc;
}
#rightSidebar {
width:100px;
height:200px;
float:right;
border:1px solid #CCC;
}
I would think the #rightSidebar div would float to the very top right corner of the #wrapper div, however, it's staying below the #maintitle DIV.
The #maintitle DIV is floating to the left, would it then allow the #rightsidebar div to float to the very top right corner?
Here it is in action, http://jsfiddle.net/BdpU7/.

Is this what you had in mind? http://jsfiddle.net/BdpU7/1/
The #rightSidebar needs to go before #sidebar in the HTML, and then #sidebar has to have the clear:
#wrapper {
width:960px;
border:1px solid red;
overflow:hidden;
}
#maintitle {
width:600px;
height:50px;
float:left;
border:1px solid #333;
}
#sidebar {
clear:left;
float:left;
width:100px;
height:200px;
border:1px solid #ccc;
}
#rightSidebar {
width:100px;
height:200px;
float:right;
border:1px solid green;
}
<div id="wrapper">
<div id="maintitle"></div>
<div id="rightSidebar"></div>
<div id="sidebar"></div>
</div>

Related

css applying a percentage to the height?

In the css code how does the percentage work, 100% of what?
.menu-side {
background-color:#333;
border-right: 1px solid #000;
color:#fff;
position:fixed;
top:0px;
left:0px;
width:210px;
height:100%;
}

Dynamically Size Div

I'm doing some HTML and am running into an issue with my left and right column divs not scaling based on the content inside them as well as in proportion to the rest of the page.
Here's my example:
http://i.imgur.com/9vi2EK9.png
And my CSS for each of the divs:
#wrapper{
background:white;
width:1280px;
position:relative;
border: 1px solid black; /* black border */
margin:auto; /* centre this div */
}
#header{
height:90px;
text-align:center;
padding: .5em;
background-color: grey;
border-bottom: 2px solid black;
}
#leftmenu{
width:100px;
float:left;
font-size: 75%;
padding:.5em;
border-right:2px solid black;
border-left:2px solid black,
}
#rightmenu{
width:180px;
float:right;
font-size: 75%;
padding:.5em;
border-left:2px solid black;
border-right:1px solid black;
}
#content{
background-color:white;
margin-left:120px;
font-size: 80%;
}
#footer{
clear:both; /* push footer under other divs */
height: 70px;
background-color:white;
border-top:1px solid black;
border: 1px solid black;
padding-top:40px;
text-align:center;
font-size: 70%;
}
How can I ensure that my divs resize based on the content in my other divs?
Thanks!
Without seeing your HTML, here's a stab at it:
JSFiddle here: http://jsfiddle.net/2hf8q/
CSS
html, body {
height: 100%;
}
#wrapper {
height: calc(100% - 2px); /* for border */
}
#leftmenu, #rightmenu {
height: calc(100% - 234px); /* for header, footer */
}
#wrapper {
background:white;
width:100%;
position:relative;
border: 1px solid black;
/* black border */
margin:auto;
/* centre this div */
}
#header {
height:90px;
text-align:center;
padding: .5em;
background-color: grey;
border-bottom: 2px solid black;
}
#leftmenu {
width:100px;
float:left;
font-size: 75%;
padding:.5em;
border-right:2px solid black;
border-left:2px solid black;
}
#rightmenu {
width:180px;
float:right;
font-size: 75%;
padding:.5em;
border-left:2px solid black;
border-right:1px solid black;
}
#content {
background-color:white;
margin-left:120px;
font-size: 80%;
}
#footer {
clear:both;
/* push footer under other divs */
height: 70px;
background-color:white;
border-top:1px solid black;
border: 1px solid black;
padding-top:40px;
text-align:center;
font-size: 70%;
}
HTML
<div id="wrapper">
<div id="header"></div>
<div id="leftmenu"></div>
<div id="content"></div>
<div id="rightmenu"></div>
<div id="footer"></div>
</div>
You can do it by wrapping #leftmenu, #content and #rightmenu in a div that is displayed as a table. And display the three children as a table-cell:
HTML:
<div id="header">#header</div>
<div id="wrapper">
<div id="leftmenu">#leftmenu</div>
<div id="content">#content</div>
<div id="rightmenu">#rightmenu</div>
</div>
<div id="footer">#footer</div>
CSS (without colors, padding, font sizes and stuff):
html, body {
margin: 0;
padding: 0;
}
#header{
height:90px;
}
#wrapper {
display: table;
table-layout: fixed;
width: 100%;
}
#wrapper > div {
display: table-cell;
}
#leftmenu{
width:100px;
}
#rightmenu{
width:180px;
}
#content{
}
#footer{
height: 70px;
}
And a working demo.

How to center the divs that float: left in responsive layout?

I need to center the divs that float: left in responsive layout. I mean to center them in small layout, even if they moves to new line. http://jsfiddle.net/allegrissimo123/njpCe/
<div class="buttonwrapper">
<div class="buttons">
Button 1
Button 2
Button 3
Button 4
</div>
</div>
.buttons a, .buttons button{
display:block;
float:left;
margin:0 7px 0 0;
background-color:#f5f5f5;
border:1px solid #dedede;
border-top:1px solid #eee;
border-left:1px solid #eee;
font-size:100%;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#565656;
cursor:pointer;
padding:5px 10px 6px 7px;
}
.buttons
{
text-align:center;
margin: 0 auto;
position:relative;
float:left;
left:-50%;
}
.buttonwrapper
{
position:relative;
float:left;
left:50%;
}
Made a little change to your code .
USe
.buttons a, .buttons button {
display:inline-block;
margin:auto;
}
check this fiddle: Fiddle

How to create speech-bubble border with CSS3

I want to create a stylized border with CSS3 like the below image. But, I don't know how? Here is the image:
Like this: http://nicolasgallagher.com/pure-css-speech-bubbles/
.triangle-isosceles {
position:relative;
padding:15px;
margin:1em 0 3em;
color:#000;
background:#f3961c;
/* css3 */
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
background:-moz-linear-gradient(top, #f9d835, #f3961c);
background:linear-gradient(top, #f9d835, #f3961c);
}
/* creates triangle */
.triangle-isosceles:after {
content:"";
display:block; /* reduce the damage in FF3.0 */
position:absolute;
bottom:-15px;
left:50px;
width:0;
border-width:15px 15px 0;
border-style:solid;
border-color:#f3961c transparent;
}
<style type="text/css">
.comments .comment{
width:10%;
margin-bottom:20px;
}
.comments .comment p{
margin:0 0 10px 0;
}
.bubble{
position:relative;
background-color:#CCC;
padding:20px;
color:#009;
border-radius:3px;
margin-left:20px;
}
.bubble::after{
content:"";
display:block;
position:absolute;
left:-15px;
top:15px;
width:0px;
height:0px;
border-top:8px solid transparent;
border-bottom:8px solid transparent;
border-right:15px solid #CCC;
}
</style>
<div class="comments">
<div class="comment bubble">
<p>This is comment</p>
</div>
</div>
you can use CSS3 box_round:
.box_round {
-webkit-border-radius: 5px;
border-radius: 5px;
}
try this site :)

CSS post alignment

I am trying to make the posts within #post-area align center instead of left. I have tried to adjust the float:left; on the .type-post to margin:0 auto; without any response.
HTML:
<div id="post-area">
<div id="post-24" class="post-24 post type-post status-publish format-standard hentry category-portfolio">
<div class="gridly-image"><img width="310" height="221" src="#" class="attachment-summary-image wp-post-image" alt="#" title="#"/></div>
<div class="gridly-category"><p>Portfolio</p></div>
<div class="gridly-copy"><h2>#</h2>
<p class="gridly-date">February 23, 2012 </p>
<p class="gridly-link">View more →</p>
</div>
</div>
CSS:
/* post and page styles */
.type-post { width:770px; background:#FFF; border-right:1px solid #dbdbdb; border-bottom:1px solid #dbdbdb; margin-right:10px; margin-top:15px; display:inline;}
.type-page { width:770px; background:#FFF; border-right:1px solid #dbdbdb; border-bottom:1px solid #dbdbdb; margin-right:10px; margin-top:15px; display:inline; float:left; }
.type-attachment { width:770px; background:#FFF; border-right:1px solid #dbdbdb; border-bottom:1px solid #dbdbdb; margin-right:10px; margin-top:15px; display:inline; float:left; }
.gridly-image { z-index:5; }
.gridly-category { position:absolute; width:auto; background:#8f4988; margin-top:-35px; z-index:10; height:30px; overflow:hidden;}
.gridly-category p { margin:0; padding:0; line-height:30px; padding-left:20px; padding-right:40px; color:#fff;}
.gridly-category a { color:#fff; font-style:italic;}
.gridly-category a:hover { color:#555;}
.gridly-copy { width:710px; margin-left:auto; margin-right:auto; margin-top:20px; margin-bottom:20px; overflow:hidden; }
.gridly-date { width:150px; color:#8e8e8e; font-size:11px;}
.size-full { width:100%; height:inherit;}
/* post index styles */
#post-area {margin:0 0 0 15px;}
#post-area .post { width:310px; background:#FFF; border-bottom-right-radius:5px; border-bottom-left-radius:5px; margin:15px 15px 15px auto; position:relative; }
#post-area .post .gridly-copy { width:250px; margin-left:auto; margin-right:auto; margin-top:10px; margin-bottom:20px; overflow:hidden; clear:both;}
#post-area .post .gridly-copy h2 { font-size:14px;}
#post-area .post .gridly-date { width:150px; color:#8e8e8e; font-size:11px; border-bottom:1px dotted #cccccc; padding-bottom:0; padding-top:0; }
#post-area .post .gridly-link { width:150px; border-top:1px dotted #e8e8e8; color:#494e51;}
#post-area .post .gridly-image img { border-top-right-radius:5px; border-top-left-radius:5px;}
Change .type-post{display:inline} to .type-post{margin:0 auto} removing display:inline.
Replace display:block instead of display:inline then it should work
in file jquery.masonry.min.js set
isFitWidth:true
add in css
#post-area
{
margin: 0 auto;
width: 100%;
}

Resources