I have this element I'm trying to develop where on the X axis, I need to scroll, but on the Y axis, I would need to see the overflow.
Its selects where you may scroll through the selects, but when you open one you need to still see the options.
But when I ask 'overflow-x:scroll', the overflow-y is forced to scroll or be hidden. overflow-y is ignored.
Is there a way to make it so the overflow on the x is kept on scroll (or is scrollable) but the y axis can still overflow its container?
EDIT: Added a quick example of how my code looks and what I'm working with.
.scroller {
max-width: 300px;
overflow-x: scroll;
overflow-y: visible;
white-space: nowrap;
padding: 16px 0;
}
.select {
display: inline-block;
position: relative;
box-sizing: border-box;
width: 100px;
margin-right: 16px;
}
.selectLabel {
width: 100%;
border: 1px solid #000;
padding: 8px;
box-sizing: border-box;
}
.selectOptions {
position: absolute;
top: 100%;
left: 0;
width: 100%;
border: 1px solid #000;
padding: 8px;
box-sizing: border-box;
}
<div class="scroller">
<div class="select">
<div class="selectLabel">Hello</div>
<div class="selectOptions">
Hello<br /> World
<br /> And
<br /> Stack
</div>
</div>
<div class="select">
<div class="selectLabel">Hello</div>
<div class="selectOptions">
Hello<br /> World
<br /> And
<br /> Stack
</div>
</div>
<div class="select">
<div class="selectLabel">Hello</div>
<div class="selectOptions">
Hello<br /> World
<br /> And
<br /> Stack
</div>
</div>
<div class="select">
<div class="selectLabel">Hello</div>
<div class="selectOptions">
Hello<br /> World
<br /> And
<br /> Stack
</div>
</div>
<div class="select">
<div class="selectLabel">Hello</div>
<div class="selectOptions">
Hello<br /> World
<br /> And
<br /> Stack
</div>
</div>
</div>
Give this a go
overflow-x: scroll;
overflow-y: visible;
Related
I have a text that overflows from its own background, when it reaches this size it stays like this:
I want the font to be smaller and don't overflow so it looks nice but I can't make it work. I tried putting a fixed width and it didn't work, also I wrote an "!important" and it didn't make a difference but when I use another CSS rules for other content it works after that so I guess the code is working.
The stylesheets are well related:
Máster en CSS
This is the HTML of the aside:
<aside id="lateralBar" class="clearfix">
<h3>
Buscar
</h3>
<div id="search">
<form action="#">
<input type="text">
<input type="button" value="L" class="icon">
</form>
</div>
<h3>
Login
</h3>
<div id="login" class="lateralBox">
<form action="">
<label id="user" class="icon">U</label>
<input type="email">
<label id="password" class="icon">w</label>
<input type="password">
<input type="submit" value="Entrar">
<input type="reset" value="Limpiar">
Registrate aquí
¿Has olvidado tu contraseña?
</form>
</div>
<h3>
Redes sociales
</h3>
<div id="socialNetwork" class="lateralBox">
<div class="twitter">
t
<p class="overlay">
Twitter
</p>
</div>
<div class="facebook">
f
<p class="overlay">
Facebook
</p>
</div>
<div class="youtube">
y
<p class="overlay">
Youtube
</p>
</div>
</div>
<h3>
Patrocinadores
</h3>
<div id="sponsors" class="lateralBox">
</div>
</aside>
The normal CSS:
#lateralBar {
width: 300px;
min-height: 1200px;
font-family: "TrebuchetMS";
float: right;
margin: 20px;
margin-right: 82px;
}
#lateralBar h3 {
display: block;
width: auto;
height: 45px;
line-height: 49px;
background: url("../img/pxgray.png"), white;
box-shadow: 0px 1px 0px #393d3f, 1px 2px 0px #393d3f, 2px 3px 0px #393d3f, 3px 4px 0px #393d3f;
font-size: 30px;
font-family: "BebasNeue";
font-weight: normal;
letter-spacing: 2px;
padding-left: 15px;
margin-top: 30px;
margin-bottom: 15px;
}
#lateralBar h3:first-child {
margin-top: 0px;
}
The responsive CSS:
#media (max-width: 899){
#lateralBar {
margin-left: 100px;
}
#lateralBar h3 {
font-size: 10px;
}
}
The issue stands on the way you defined your media.
Try adding 'px' on your max-width and that should work:
#media (max-width: 899px){ .. }
Elements doesn't align to centre when margin: 0 auto; applied.
See the code here. https://jsfiddle.net/helloworld123/vhhx1o7n/
I have to align the elements in centre of page(.entry-wrap should be aligned to centre of the page) and its children(.entry) should be floated to left.
I have this working to some extent in fiddle https://jsfiddle.net/helloworld123/n8o18ges/ ,but I don't want the elements in third row to be aligned to center.
<div class="entry-wrap">
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
</div>
body {
background: #f8f8f8;
}
.entry-wrap {
width: 500px;
height: auto;
margin: 0 auto;
background: #ccc;
padding: 10px;
}
.entry {
float: left;
border: 1px solid #f1f1f1;
margin: 2px;
}
This is what I want to achieve
1.) On .entry, use display: inline-block; instead of float: left;
2.) On .entry-wrap use text-align: center;
https://jsfiddle.net/fe6cmr07/
First of all, all the elements inside entry-wrap are floated, so entry-wrap is collapsing, to fix it, you can add overflow:hidden to it, or use a clearfix solution.
If you want the child elements to be centered, it's just a matter of playing with the width of the wrapping div:
body {
background: #f8f8f8;
}
.entry-wrap {
width: 620px;
margin: 0 auto;
padding: 15px;
background: #ccc;
overflow: hidden;
}
.entry {
float: left;
border: 1px solid #f1f1f1;
margin: 2px;
}
fiddle: https://jsfiddle.net/o8aj3hqL/
your block with margin: 0 auto is in the center of <body>. the problem is with the child elements since they are floated and it won't be center aligned unless you use display: inline-block instead of float: left
here is the fiddle https://jsfiddle.net/vhhx1o7n/1/
body {
background: #f8f8f8;
}
.entry-wrap {
width: 618px;
height: 318px;
margin: 0 auto;
background: #ccc;
padding: 10px;
}
.entry {
float: left;
border: 1px solid #f1f1f1;
margin: 2px;
}
<div class="entry-wrap">
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
<div class="entry">
<img src="https://d13yacurqjgara.cloudfront.net/users/43342/screenshots/2772190/dribbble_2016_partb_001_teaser.jpg" alt="Shot title" />
</div>
</div>
I'm having a (probably stupid) problem with floating div. I have each div sized at one or two-thirds of screen width (on wide enough displays).
Where I have a short 67% div floated left then a tall 33% div floated right then a short 67% div floated left, I'd expect the third div lined up immediately underneath the first with the second continuing down to its right, as at http://jsfiddle.net/BluefireAdz/bqdpfv8w/
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #aaaa00; color: #ffffff; ">
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #aa0000; color: #ffffff; ">
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: right; width: 33%; background-color: #00aa00; color: #ffffff; ">
<br />
<br />
<br />
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #0000aa; color: #ffffff; ">
<br />
</div>
However, something (probably in my CSS) is pushing it down so that it only starts at the bottom of the second div, as at http://jsfiddle.net/BluefireAdz/9bho8s5b/ (code made as clean as I can easily make it and still having the problem).
<div class="w67" style="background-color: #aaaa00; ">
<h1>Title</h1>
</div>
<div class="w67" style="background-color: #aa0000; ">
<div class="b3_vplayer">
<div class="embed-container">
<iframe src="http://www.youtube.com/embed/06olHmcJjS0?autoplay=0&rel=0&theme=light" style="border: 0; "></iframe>
</div>
</div>
</div>
<div class="w33" style="background-color: #00aa00; ">
<img src="http://www.killersites.com0killerSites/resources/dot_clear.gif" alt="Image 1" style="width: 286px; height: 300px; margin: 1em 0 0 0" />
<img src="http://www.killersites.com/killerSites/resources/dot_clear.gif" alt="Image 2" style="width: 286px; height: 300px; margin: 1em 0 0 0" />
</div>
<div class="w67" style="background-color: #0000aa; ">
<p>Lorem Ipsum</p>
</div>
Have tried in Edge, IE and Firefox and get the same results.
See my updated fiddle here: http://jsfiddle.net/9bho8s5b/1/
Basically I just brought the floated right div before the other divs.
<div style="padding: 0; margin: 0; border: 0; float: right; width: 33%; background-color: #00aa00; color: #ffffff; ">
<br />
<br />
<br />
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #aaaa00; color: #ffffff; ">
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #aa0000; color: #ffffff; ">
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 67%; background-color: #0000aa; color: #ffffff;">
<br />
</div>
Update your code in this fiddle
http://jsfiddle.net/9bho8s5b/2/
HTML:
<div style="float:left; width: 67%;">
<div style="padding: 0; margin: 0; border: 0; float: left; width: 100%; background-color: #aaaa00; color: #ffffff; ">
<br />
</div>
<div style="padding: 0; margin: 0; border: 0; float: left; width: 100%; background-color: #aa0000; color: #ffffff; ">
<br />
</div>
</div>
You can wrap your first two div's in another div which is of 67% width and the internal divs which take full width.
You can change up your HTML so that the div that is set to float:right appears first, followed by the 3 float:left.
Here is a fiddle.
Solved it - I wasn't actually floating the w33 div to the right! Have added float: right to the inline style and now it all floats as hoped for!
I am attempting to put together a web page that has four areas: a header, footer, content, and controls. The header and footer should be fixed at the top and bottom of the page (respectively) and automatically size to their content. The controls should go on the far right side of the page (vertically between the header and footer) and is fixed-width. The content area should fill the remainder of the page.
I had this working, but now whenever I add any kind of content (even just a single-word paragraph element), the controls area moves to almost the very bottom of the page. You can see what I'm referring to here: http://jsfiddle.net/ym8vY/1/
If I leave the controls div completely empty, it lays out exactly how I want it: http://jsfiddle.net/ym8vY/
My body currently looks like:
<header>
<p>Header</p>
</header>
<div class="main">
<div id="streamGraph" class="page">
<div class="page-row">
<div class="page-content-container-outer">
<div class="page-content-container-inner">
<div id="graphContainer" class="page-content"></div>
</div>
</div>
<div class="page-controls-container-outer">
<div class="page-controls-container-inner">
<div class="page-controls"><!-- If anything goes inside here, it breaks -->
<div style="display: table; height: 100%;">
<div style="display: table-row; height: 0;">
<div>
<label for="sampleCount"># Samples:</label>
<input type="text" id="sampleCount" name="sampleCount" value="100" />
</div>
<div>
<label for="tagCount"># Tags:</label>
<input type="text" id="tagCount" name="tagCount" value="25" />
</div>
<div>
<label for="fromDate">From:</label>
<input type="date" id="fromDate" name="fromDate" />
</div>
<div>
<label for="toDate">To:</label>
<input type="date" id="toDate" name="toDate" />
</div>
<button id="tagsButton">Customize Tags</button>
<button id="refreshButton">Apply</button>
</div>
<div style="display: table-row;">
<div id="tagContainer" style="overflow: auto; height: 100%;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<p>Footer</p>
</footer>
And my CSS is:
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
display: table;
}
header, .main, footer {
display: table-row;
width: 100%;
}
header, footer {
background: lightgray;
}
.main {
height: 100%;
}
.page {
height: 100%;
display: table;
}
.page-row {
display: table-row;
width: 100%;
}
.page-content-container-outer {
display: table-cell;
width: 100%;
height: 100%;
padding: 10px;
}
.page-controls-container-outer {
display: table-cell;
height: 100%;
padding: 10px;
}
.page-content-container-inner {
border: solid;
border-color: gainsboro;
border-width: 5px;
border-radius: 10px;
width: 100%;
height: 100%;
padding: 5px;
}
.page-controls-container-inner {
border: solid;
border-color: gainsboro;
border-width: 5px;
border-radius: 10px;
height: 100%;
padding: 5px;
}
.page-controls {
height: 100%;
width: 300px;
}
.page-content {
height: 100%;
}
Your right-side div is being pushed down to the baseline. Add vertical-align:top to fix it:
div
{
vertical-align: top;
}
JSFiddle
Side note: The default value for vertical-align is baseline. Always keep this in mind when using cells and inline-blocks.
Add vertical-align:top; to your .page-controls-container-outer class
Change this
<div style="display: table-row; height: 0;">
to this
<div style="display: table-row; height: 0; float:left;">
I tried to create a new layout for my site using inline-block instead of float.
<div id="container">
<div class="row"><!-- HEADER -->
<div class="pan1">
<div class="content">
HEADER LEFT PANEL <br /><br />
</div>
</div>
<div class="pan2">
<div class="content">
HEADER RIGHT PANEL <br/></div>
</div>
</div>
</div><!-- END HEADER -->
<div class="row"><!-- MAIN -->
<div class="pan3">
<div class="content">
MAIN LEFT PANEL <br /><br />
</div>
</div>
<div class="pan4">
<div class="content">
MAIN RIGHT PANEL <br/></div>
</div>
</div>
</div><!-- END MAIN -->
</div>
CSS
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #f5f6f7;
}
#container {
width: 960px;
margin-left: auto;
margin-right: auto;
background: #ccc;
}
.row {
margin-top: 10px;
background: #fff;
padding: 0px;
}
.pan1 {
width: 700px;
display: inline-block;
vertical-align: top;
*zoom: 1;
*display: inline;
padding: 0px;
font-size: 0;
}
.pan2 {
width: 256px;
display: inline-block;
vertical-align: top;
*zoom: 1;
*display: inline;
padding: 0px;
font-size: 0;
}
.pan3 {
width: 500px;
display: inline-block;
vertical-align: top;
*zoom: 1;
*display: inline;
padding: 0px;
font-size: 0;
}
.pan4 {
width: 456px;
display: inline-block;
vertical-align: top;
*zoom: 1;
*display: inline;
padding: 0px;
font-size: 0;
}
.content {
padding: 0px;
border: 1px solid #000;
font-size: 12px;
}
unfortunately I can not understand why it is not considered the hack to remove the white space between panels inline-block and also the main block turns out to be not aligned with my header block. Can you give me any suggestions on how I could make a correct layout? thanks
the problem is within your html tags. you put other/extra ending </div> that is why the main block is not aligned like the header block
to remove the white space you will need to do this
<div>
// content
</div><div>
// content
</div>
<div id="container">
<div class="row"><!-- HEADER -->
<div class="pan1">
<div class="content">
HEADER LEFT PANEL <br /><br />
</div>
</div><div class="pan2">
<div class="content">
HEADER RIGHT PANEL <br/>
</div>
</div>
</div><!-- END HEADER -->
<div class="row"><!-- MAIN -->
<div class="pan3">
<div class="content">
MAIN LEFT PANEL <br /><br />
</div>
</div><div class="pan4">
<div class="content">
MAIN RIGHT PANEL <br/>
</div>
</div>
</div><!-- END MAIN -->
</div><!-- END CONTAINER -->
look at this for the demo
To remove spaces between blocks, you can try to write your html like this:
<div>
...
</div><div>
...
</div>
Having element start just after an other one will prevent the browser to add whitespaces between elements. It also means that you can't have newlines between elements. If I was you, I could instead think of using a minificator that will remove unnecessary whitespaces.