displaying a div inline with the 1st div of a list of block divs

Go To StackoverFlow.com

0

sorry this is such a simple question but I can't figure it out. How to display a div inline with the 1st div of a list of block divs.

here's a jsfiddle so you can see what I mean: http://jsfiddle.net/trpeters1/u6pt6/11/

here's the HTML for that:

<div class="">1</div>
<div class="">2</div>
<div class="">3</div>
<div class="title">this is my title</div>

and here's the CSS:

div{
    width:30px;
    height:30px;
    margin:1px;
    background:red;
}

In this example I'd like the div with class="title" to be displayed inline alongside the number 1 and not at the bottom beneath the number 3 as it currently stands. An important caveat is that the first 3 divs need to stay together because they are rendered by some php code. So non-nesting based solutions are preferred.

thanks for your help,

tim

2012-04-05 00:35
by tim peterson
hi mshayem, thanks for your help, sorry I left out a key piece of info, the first 3 divs have to stay together because they are rendered by some php code. Is there any work arounds not involving nesting of the divs - tim peterson 2012-04-05 00:40


1

Like this?

<section>
    <div>1</div>
    <div>2</div>
    <div>3</div>
</section>
<section>
    <div class="title">this is my title</div>
</section>

div{
    width:30px;
        height:30px;
        margin:1px;
        background:red;
}
section{
    float:left;
}
.title {
    width: 150px;
}

Title on the right: http://jsfiddle.net/u6pt6/13/

Title on the left: http://jsfiddle.net/u6pt6/14/

2012-04-05 00:40
by AlienWebguy
Sweet, thanks AlienWebguy. I've avoided thinking of section tags for fear of lack of browser support. Though that doesn't appear to be the case, right?: http://caniuse.com/#search=sectio - tim peterson 2012-04-05 00:44
thanks for the second fiddle too - tim peterson 2012-04-05 00:44
You could easily replace <section> with <div class="section"> and change the css to point to .sectionAlienWebguy 2012-04-05 00:46
yep, right on! thanks again - tim peterson 2012-04-05 00:50
Ads