SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Layout issue - structural container not expaning full width of layout

    I have a site I'm re-skinning that I have run across and issue with. It seems as if one of my structural elements is not expanding to the full width of the layout.

    Consequently, content is being cut-off. For some browsers, I can hide the issue by applying the "overflow-x" property to my html element. However, this doesn't work on mobile versions of Safari and, as a solution, it isn't something I want to use.

    My access to the html is limited and there are a number of issues I'm aware of but I'm unsure those issues are contributing to this specific problem.

    Just curious if someone might be able to provide insight?.

    Site-Here

  2. #2
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,507
    Mentioned
    61 Post(s)
    Tagged
    2 Thread(s)
    Hi, MichaelRubens. Welcome to the forums.

    Assigning {overflow-x:hidden} to the html element removes horizontal scroll bars, so that's probably not the best choice.

    Which element is not expanding to the full width of the layout and under what conditions?

    You mentioned the mobile version of Safari, but I am not seeing the page scale down in desktop Firefox, beyond a couple of early, short steps.

    It would help us if you would describe which elements are misbehaving and how, in which browsers, give class and/or ID names, if possible, and where they appear on the screen/page.

  3. #3
    SitePoint Member
    Join Date
    Apr 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the welcome. As I had indicated, I completely understand that applying the "overflow-x" property is not the ideal solution. However, in the real world where things are not so clean and inflexible deadlines exist we made a choice to go-live the better of 2 poor options rather than to allow this issue to present itself in all viewing situations.

    What we have is a fairly common "banned" layout; i.e. a number of stacked containers that within each have a container that is centered and which serves as the main site body:e.g.
    Code:
    <html>
      <body>
        <div class="container">
          <div class="content">...site stuff here...</div>
        </div>
        <div class="container">
          <div class="content">...site stuff here...</div>
        </div>
        <div class="container">
          <div class="content">...site stuff here...</div>
        </div>
      </body>
    </html>
    Where
    Code:
    .container {
        padding:4em 0;
        position:relative;
        overflow:hidden;
        width:100%;
        z-index:100;
        }
    
        .content {
            background:#fffff;
            margin:0 auto;
            position:relative;
            width:1280px;
            }
    The issue here is that our div.container is not expanding to the full width of the website and quite frankly, I have no idea why. It's as if the .container element is aligning its width to the viewport/window width, not the site.

    Please be aware this isn't a Responsive solution.

    This re-skin is not going to be a long lived solution so I'm willing to embrace any possibility for correcting this issue.

    Again, thank you for taking time out to read this post.

    Regards,

    M. Rubens

  4. #4
    SitePoint Member
    Join Date
    Apr 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been able to determine the offending container. A wrapper div#main with

    Code:
    #main{
    padding-bottom:175px;
    position:relative;
    }
    that inherits a number of defaults:
    Code:
    {
        border: 0 none;
        font: inherit;
        margin: 0;
        outline: 0 none;
        padding: 0;
        vertical-align: baseline;
    }
    This seems to be the container that is not expanding.

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,355
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by MichaelRubens View Post


    The issue here is that our div.container is not expanding to the full width of the website and quite frankly, I have no idea why. It's as if the .container element is aligning its width to the viewport/window width, not the site.
    You have answered your own question in some respects here .

    The container is a wrapper and its width is auto (effectively 100% for a static element) whic means that .container will be the width of the viewport. However .content is 1280px wide which means that only when the viewport is wider than 1280px will that element fit inside .container.

    When the viewport is less than 1280px wide then .content can no longer fit and it overflows the parent. That means as far as .container is concerned anything that sticks out will be ignored as far as the flow of the page is concerned. That's just how CSS works . If an element is too big to fit in its container then it sticks out (because overflow:visible is the default). It no longer then takes part in the flow of the page.

    When you have wide fixed width elements in the page and your containers are auto or 100% width then you must also set a min-width equal to the largest element in that page.

    e.g.
    Code:
    #main,.container{min-width:1280px}
    I hope that explains it for you (and I hope it was the issue you were talking about ).


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
  •