Results 1 to 5 of 5

Thread: Displaying two divs on the same line

  1. #1
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Displaying two divs on the same line

    Does anyone know an easy way to display two divs on the same line? The two divs are in a parent div that sets its position. This is the code:

    Code:
    <div id="legend">
                	<div id="greenbox"></div> <div class="legendtext">= originals</div>
                	<br>
                    <br>
                    <div id="bluebox"></div> <div class="legendtext">= arrangements</div>
                </div>
    CSS:
    Code:
    #legend {
    	position:absolute;
    	float:right;
    	top:200px;
    	right:75px;
    	width:200px;
    }
    
    .legendtext {
    	display:inline;
    }
    
    #greenbox {
    	width:8px;
    	height:8px;
    	background-color:#006633;
    }
    
    #bluebox {
    	width:8px;
    	height:8px;
    	background-color:#06F;
    }
    This is how I want it to look, where [greenbox]/[bluebox] is just a 8 pixel colored box by CSS:
    [greenbox] = originals
    [bluebox] = arrangements

    But this is how it appears:
    [greenbox]
    = originals
    [bluebox]
    = arrangements

    I've tried "display:inline;" and "float", neither works.

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there windbrand,

    here is a totally different way of tackling your problem, which may amuse you...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title></title>
    
    <style type="text/css">
    body {
        margin:10px;
        background-color:#f0f0f0;
     }
    ul { 
        float:right;
        width:200px;
        margin:170px 75px 0 0;
        list-style-type:square;
        font-family:verdana,arial,hevetica,sans-serif;
        font-size:20px;
        background-color:#fff;
        box-shadow:#333 4px 4px 4px;
     }
    li {
        padding:10px 0
     }
    #green {
        color:#063;
     }
    #blue {
        color:#06f;
     }
    ul span {
        float:left;
        margin:8px 0 0 -5px;
        font-size:10px;
        color:#000;
     }
    </style>
    
    </head>
    <body>
    
    <ul>
     <li id="green"><span>= originals</span></li>
     <li id="blue"><span>= arrangements</span></li>
    </ul>
    
    </body>
    </html>
    
    coothead

  3. #3
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks the list idea works. I had to slightly modify it and remove the extra styling.
    I guess a much easier way is to just use an image for a bullet. Is there a way to change the size of the list bullet?

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there windbrand,

    as your seemed to want to have an 8px by 8px square, I set the ul font-size to 20px.

    Increasing that value will make the bullet larger.

    coothead

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    alternatively (a little closer to what you were trying to do):
    Code:
    .legendtext{ width: 200px; font-size: 16px; }
    .greenbox,.bluebox{ width: 8px; height: 8px; display: inline-block; margin: 2px 6px; }
      /* adjust margin as desired for spacing */
    .greenbox{ background: #006633; }
    .bluebox{ background: #06F; }
    HTML Code:
    <div class="legendtext">
       <div class="greenbox"></div>
       = originals
    </div>
    <div class="legendtext">
       <div class="bluebox"></div>
       = arrangements
    </div>
    result:

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •