Float CSS Problem

Discussion in 'HTML & Website Design' started by moneysharma, Oct 26, 2012.

  1. #1
    can anyone tell me how to solve this problem? Picture attached here.


    Div1 is floated left;


    Div2 was isn't floated left so it goes like this;when was floated it goes entirely below Div1(due to width problem).


    Also please tell me how can we make container of the size of its floated contents?




    Thankyou
     

    Attached Files:

    moneysharma, Oct 26, 2012 IP
  2. carleywatson

    carleywatson Banned

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can visit at w3school. there are many CSS example.
     
    carleywatson, Oct 27, 2012 IP
  3. MediWorm

    MediWorm Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Give padding-left 15px;
    and you don't need to float it to the right ok!
     
    MediWorm, Oct 27, 2012 IP
  4. knewedge

    knewedge Active Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #4
    Also, read up on clearing floats. Will save some future headaches.
     
    knewedge, Oct 27, 2012 IP
  5. srirambyrapaneni

    srirambyrapaneni Active Member

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #5
    i can solve it if you provide me the uel
     
    srirambyrapaneni, Oct 31, 2012 IP
  6. jhony king

    jhony king Member

    Messages:
    460
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    38
    #6
    Let suppose code in this use 980px width and height 700px of main page and give name of main div and inside it use 2 class div.
    Suppose HTML code
    <div id="mainbox">
    <div class="left"> Left Side </div>
    <div class="right"> Right Side <br /> </div>
    </div>
    CSS code
    #mainbox {
    background-color: #FC9;
    height: 700px;
    width: 980px;
    }


    .left {
    background-color:#0FC;
    height: 300px;
    width: 200px;
    float:left;
    }


    .right {
    background-color:#369;
    height: 700px;
    width: 780px;
    float:right;
    }
     
    jhony king, Nov 1, 2012 IP
  7. coder77

    coder77 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hello man, if you use firefox browser, you need addons firebug to solve all the problem.
     
    coder77, Nov 1, 2012 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Not entirely sure what you are even asking -- are you trying to make it so DIV2 doesn't auto-indent and/or stretch underneath the float? If so you just set overflow:hidden on it for 'modern' browsers, and a haslayout trigger (like zoom:1;) for legacy versions of IE.

    Though if you're doing a fluid layout, it's often more stable to do the 'extra DIV and negative margin float' trick to make sure it always behaves without float drop.

    Either way, fixing the width is NOT the answer, since you shouldn't have an inaccessible train wreck of a website in the first place. The too big for a netbook and crappy little stripe on desktop method of site design being some of the biggest asshattery this side of declaring all your fonts in pixels and using insufficient color contrasts -- the trifecta of failure in the age of responsive layout.
     
    deathshadow, Nov 1, 2012 IP