Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS auto resize div

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #146416
    Hamed
    Participant

    Hi, i want to have 4 blocks of divs:
    -# main size specified
    -# one size specified
    but #two with content 1 must stay beside of #one ( not over it! )
    and #two with content 2 must have 100% of width… here is the code:

    #main {
        display: block;
        margin: 0 auto 0 auto;
        width: 800px;
        height: 1000px;
        border: 2px solid black;
    }
    #one{
        display: block;
        float: right;
        width: 200px;
        height: 400px;
        border: 2px solid blue;
    }
    #two{
        display: block;
        float: left;
        width: 100%;
        height: 400px;
        border: 4px solid red;
        margin: 0 0 10px 0;
    }
    

    < div id = “main” >
    < div id = “one” >sidebar< /div >
    < div id = “two” >content 1< /div >
    < div id = “two” >content 2< /div >
    < /div >

    is it possible?

    #146418
    Paulie_D
    Member

    Have you tried making a Codepen?

    #146420
    Hamed
    Participant

    http://codepen.io/anon/pen/defnG
    i don’t know why # two come over # one or push it down!

    #146424
    Paulie_D
    Member

    You can’t use the same ID on two elements.

    You might want to look into that….oh, and a clearfix as well.

    #146426
    Hamed
    Participant

    thanks for you reply
    do you see google plus post format?
    2 of posts is in half size 50%-50% and one of them have 100% width
    it’s must to be like that…
    here is a image of what i want:

    http://d.pictureupload.us/13197628025207f9ff225f3.jpg

    it’s so important for me to have one id for two elements…

    #146428
    chrisburton
    Participant
    #146429
    Paulie_D
    Member

    it’s so important for me to have one id for two elements…

    It’s still wrong…you should be using classes instead.

    #146430
    Hamed
    Participant

    @chrisburton

    -# tow pushed down :(

    it’s must be stay beside of # one

    @Paulie_D

    show me a way…

    #146431
    chrisburton
    Participant

    @Hamed Paulie is right. Why is it important for you not to change the markup?

    #146432
    Hamed
    Participant

    coz it’s a blog post loop and gonna be repeat for every post…
    can’t we do it with jquery or somethink?
    any idea? please…

    #146433
    chrisburton
    Participant

    So you need to change your loop code, then.

    This is how I’d do it: http://codepen.io/chrisburton/pen/lGcvs.

    The content that goes in .main would be the latest post and the rest would go in .secondary.

    #146434
    Hamed
    Participant

    thank you chris but i have not access to loop code!
    are you sure there is no way to do it?
    any trick with css, javascript or jquery with if else or what ever ?
    there is no way at all?
    last hope :D

    #146435
    chrisburton
    Participant

    @Hamed What CMS are you using?

    #146436
    Hamed
    Participant

    it’s a specific blog service and for me in unknown language… and forget it !
    what if i use wordpress?

    #146438
    chrisburton
    Participant

    WordPress is all right. I prefer Kirby, though. Much more flexible and simpler to use from my experience.

    But whichever you choose, I think it’s important that you have control over your output.

Viewing 15 posts - 1 through 15 (of 20 total)
  • The forum ‘CSS’ is closed to new topics and replies.