CSS, display: table and overflow not working properly on child div's

xtcy

Basicly I have a webpage where users can change content inside my layout. I'm trying to force the div where the content is being put to overflow hidden or scroll.

But the width of my page keeps increasing rather then scrolling/hiding.

http://jsfiddle.net/weLn0g96/3/

Anyone more clever than me that can figure this out? Prolly missing something like position:absolute; or overflow should be somewhere else etc.

IMI

Update #container to be display:block; and overflow: scroll;. Using display:table; will make the #container element width as wide as it needs to be to hold the data and will not adhere to the 100% width of the parent element that you have declared and are trying to accomplish.

#container {
  /* Change display: table; to */ display: block;
  width: 100%;
  height: 100%;
  text-align:center;
  overflow: scroll; /* add this */
}

You should also add height:100%; to your html and body elements if you want the #container element to truly be 100% of the height of the body.

See Snippet with border added to #container for demonstration purposes.

html,
body {
  margin: 0;
  padding: 0;
  background-color: #111111;
}

#container {
  /* Change display: table; to */
  display: block;
  width: 100%;
  height: 100%;
  text-align: center;
  overflow: scroll;
  /* add this */
}

#container {
  /* styles just for demonstration */
  border: 5px solid green;
  box-sizing: border-box;
}

#row-empty {
  display: table-row;
  width: 100%;
  height: 100%;
}

#sides {
  display: table-cell;
}

#main {
  display: table-cell;
  width: 800px;
  margin: 0px;
  padding: 0px;
}

#main-table {
  display: table;
  width: 100%;
  height: 100%;
  background-color: #CCCCCC;
}

#menu {
  display: table-row;
}

#menu-col {
  display: table-cell;
  width: 100%;
  height: 100px;
  border-bottom: 1px solid #000000;
}

#page {
  display: table-row;
  width: 100%;
  height: 100%;
}

#page-col {
  display: table-cell;
  position: relative;
  background-color: yellow;
  overflow-x: hidden;
}
<div id="container">
  <div id="row-empty">

    <div id="sides">&nbsp;</div>
    <!-- Left Column -->

    <div id="main">
      <!-- Middle Column -->

      <div id="main-table">
        <!-- New table inside table-cell for rows inside this cell -->

        <div id="menu">
          <!-- Top Row -->
          <div id="menu-col">

            menu

          </div>
        </div>

        <div id="page">
          <div id="page-col">
            <!-- Middle Row -->

            testar [asdf] asdasd
            <div news style="display:inline-block;width:500px;overflow-x:auto;background-color:red;width:1500px;">Inga nyheter än.</div> xx

          </div>
        </div>

      </div>

    </div>
    <!-- Middle Column (main) end -->

    <div id="sides">&nbsp;</div>
    <!-- Right Column -->

  </div>
  <!-- row end -->
</div>
<!-- container end -->

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

CSS : Amazingly strikethrough not working on child display:inline-block div

HTML and CSS table overflow not working

Flexbox and overflow: hidden not working properly

css display flex not working properly on chrome and safari

HTML table overflow not working

CSS - display: table-cell not working properly

css overflow on both parent and child div

Ruby Table CSS - Background is not working properly

My CSS is not working properly when trying to display a div element when a p element is hovered

how to fix CSS div's not aligning properly

Display: table overflow parent div in firefox

CSS for table scroll not working properly

CSS width and height not working for div with display: inline

CSS min-height not working for child div

Child div display table-cell fixed width not working

CSS: 100% height not working on div with display: table

CSS Animations Overflow Across DIV's

CSS display table vertically and expand horizontally when overflow

overflow:hidden on a div not working properly - iOS

overflow auto on child div

CSS "display: none" property not working properly

jquery .css('display', 'block') not working properly

CSS Cut text overflow in label with display-type table

CSS Padding is not working properly, it's looking as a margin

CSS of the child element not working but parent's css is working fine

CSS table background not working properly in Outlook

prevent child div to overflow parent div css/tailwindcss

Display DIV when hovering another DIV's child CSS

CSS height Property not working for display: table?

TOP Ranking

HotTag

Archive