Forums

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

Home Forums CSS Can someone help with this flexbox problem?

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #285825
    rnbutler87
    Participant

    Hi
    I’m just experimenting with changing a template in wordpress but want to see if I can mockup a simple example first.
    I’m trying to get the blue header full width. And then underneath, have the red and black sections next to each other, with the red box taking up 2 thirds of the space and the black box taking up the remaining third.
    Here’s where I’ve got to: https://codepen.io/rnbutler87/pen/pBJVxg
    Any help would be greatly appreciated.
    Richard

    #285835
    Paulie_D
    Member

    Frankly, the HTML structure looks messed up for this.

    Yes…you’ll need to swap some things around. You want the article to be 66% wide but the header inside it to be 100% wide, that isn’t going to work.

    #285836
    rnbutler87
    Participant

    Maybe I’m wrong, but as I understand it, the article tag is just there for semantic reasons; I actually want the .article-content to be 66%, not the entire article tag itself.

    #285837
    Paulie_D
    Member

    Regardless, the header inside the element that is 66% wide can’t be 100% of the super-container.

    To get the article next to the sidebar the article needs to be 66% wide which means your header can’t be 100% wide…see?

    #285838
    rnbutler87
    Participant

    Sorry but I don’t understand, I’m probably being dense…! From how I thought I’d written the code, the header element isn’t inside anything that is 66%. The .article-content div is what I want to be 66% and the sidebar to sit next to it in the remaining space. Thanks for your patience…

    #285843
    Paulie_D
    Member

    The header is inside the article but the sidebar isn’t.

    So they can’t be next to each other because they don’t share a parent container.

    To make the header 100% wide, the article needs to be 100% but it can’t be because the article has to sit next to the side bar.

    So, either the header comes out of the article or the sidebar goes in….then it’s possible.

    #285844
    rnbutler87
    Participant

    So even though everything is in a flex container div, an article tag does not behave like a normal div?

    #285845
    rnbutler87
    Participant

    (and I really want to get my head around this so thank you for taking the time to explain it!!)

    #285847
    Paulie_D
    Member

    So even though everything is in a flex container div, an article tag does not behave like a normal div?

    It is acting like a normal div…but the fact that it’s in a flex container won’t make any difference.

    The article and sidebar are both children of the flex container so if the sidebar is 33% wide what does that leave for the article…67% right?

    So, if the article is a maximum of 67% wide, the header inside the article can’t be wider than that.

    #285870
    LearnTheNew
    Participant

    Adjust the column and rows like example i have placed a code in your codepen test
    .row{
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    }
    .col-4{width: 33.33%; background-color: black;}
    .col-8{width: 66.67%;}

    #285871
    rnbutler87
    Participant

    In response to Paulie D: Hi, thanks again for the reply. I’ve looked again and it makes sense what you’re saying. The only thing I don’t understand is that the

    <

    header> tag is not inside the

    <

    article> tag. But but does that still get affected by the sidebar %?

    EDIT Nm, I thought Header was outisde Article, it’s not….I need to go away and think about this.

    I think what I’m trying to do is honour the Article tag semantics whilst having a full width header and article content with a sidebar. I’ve seen it on other sites and I wonder if its possible

    #285883
    Paulie_D
    Member

    If you can find an example of this design we can take a look at it and see how they did it!

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