Greg
Greg

Reputation: 3063

Alignment issue - blocks under each other

would you know how to force my H1 text to be placed below the blue category button? Currently it goes next to it. Many thanks

http://jsfiddle.net/TDBzN/

enter image description here

<div id="article" class="animated2 fadeInLeftBig">
<div class="article-close"></div>
    <div class="category">#Category</div>
    <h1>This is the H1</h1>
    <p class="intro">Lorem ips um dolor sit amet, consectetur adipiscing elit. Nam sit amet diam nisl. Aliquam quis est eu elit facilisis aliquam. Pellentesque porta nunc diam <a class="various" href="#">Inline</a></p>
</div>

CSS:

#article {
    /* opacity controlled via fadeInLeftBig */
    position: absolute;
    width: 600px;
    left: 230px;
    top: 0;
    height:100%;
    background-color: #fff;
    opacity:0.9;
    padding: 30px 50px 50px 50px;
    z-index: 1000;
    box-shadow:-2px 0 5px 0 rgba(0, 0, 0, 0.5); 
}
#article .intro{
    font-family: 'Open Sans', sans-serif;
    font-weight:600;
    }

#article h1 {
    font-size: 33px;
    color:#555;
    font-style:italic;
}
#article h2 {
    color:#555;
    margin-bottom:5px;
}
#article p {
    font-style: normal;
    font-weight: 300;
    /* color: #555; */
    color: #555;
    font-size: 15px;
    line-height: 22px;
    padding: 10px 0;
    margin-top: -10px;
    text-align:justify;

    }
#article a {
    color: #F15034;
    text-decoration: none;
    font-weight: bold;
}
#article a:hover {
    border-bottom: 2px solid #F15034;
}

.category {
    float: left;
    text-align: center;
    font-size: 12px;
    color: white;
    padding: 8px 18px;
    margin: 18px 0 0 0px;
    text-decoration: none;
    -webkit-transition: background 0.3s ease;
    -moz-transition: background 0.3s ease;
    -ms-transition: background 0.3s ease;
    -o-transition: background 0.3s ease;
    transition: background 0.3s ease;
    background: rgba(71, 186, 255, 0.8);
}

Upvotes: 0

Views: 71

Answers (3)

rpasianotto
rpasianotto

Reputation: 1413

DEMO

Edit the class .category from:

.category {
float: left;  /* REMOVE */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}

TO

.category {
max-width:70px; /* EDITED */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}

and it work fine.

Upvotes: 0

Kevin Lynch
Kevin Lynch

Reputation: 24703

You should clear: both; on the h1 tag. An alternative would be to create a clear:both; <div>, but that isn't required in this instance.

DEMO: http://jsfiddle.net/TDBzN/6/;

h1 
{
    clear:both;
}

To create a clear:both; div put this in between the h1 element and the floated element, in this case that is .category.

<div style="clear: both;"></div>

This is helpful just to insert where you need an element clearing and it isn't appropiate to clear the element directly.

Upvotes: 1

Dominic Green
Dominic Green

Reputation: 10258

Put clear left on your heading should work

#article h1 {
    font-size: 33px;
    color:#555;
    font-style:italic;
    clear:left;
}

See http://jsfiddle.net/TDBzN/2/

Upvotes: 0

Related Questions