Is it bug in WebKit with min-width? - html

I was struggling with weird rendering of my web site header for hour or so and it looks like there is the bug in WebKit (e.g. latest Chrome). It is bug? Or am I missing something?
Here is the http://jsfiddle.net/y415st6s/
I expect a separator to appear between Site Title and Page Title, but get only its border overflowing over the site title. I'm using min-width to set width of block with "Site title" and I noticed it works fine at least in FireFox and IE. In WebKit it looks like inner padding is not accounted in external dimensions of the block with min-width. The problem seems to disappear when 'width' is also set to the same value (see line #28 in jsfiddle CSS).
According to https://developer.mozilla.org/en-US/docs/Web/CSS/min-width setting just min-width should override 'width' too, so it seems I'm doing it the right way.
Staff for copy/pasting ...
HTML
<header class="siteHeader hstackpanel">
<div>
<div class="siteHeader__logoArea hstackpanel">
<div class="siteHeader__logoIcon">
<img src="http://static.flaticon.com/png/16/1394.png">
</div>
<div class="siteHeader__logoText hstackpanel-autofit">Site Title</div>
<div class="siteHeader__logoButtons">
<img src="http://static.flaticon.com/png/16/9916.png">
<img src="http://static.flaticon.com/png/16/57164.png">
</div>
</div>
</div>
<div>
<!-- box with blue border -->
<div class="siteHeader__splitter"></div>
</div>
<div class="hstackpanel-autofit">
<div class="siteHeader__titleArea hstackpanel">
<div class="hstackpanel-autofit">
<div class="siteHeader__titleAreaText hstackpanel hstackpanel-autofit">
<span class="siteHeader__pageTitleText">Current Page Title</span>
</div>
</div>
<div>
<div class="siteHeader__titleAreaButtons hstackpanel"></div>
</div>
</div>
</div>
</header>
CSS
* {
box-sizing: border-box;
}
.hstackpanel {
display: table;
width: 100%;
}
.hstackpanel > div {
display: table-cell;
position: relative;
vertical-align: middle;
padding: 2px;
}
.hstackpanel > div:not(.hstackpanel-autofit) {
white-space: nowrap;
width: 0.01px;
}
img {
width: 16px;
height: 16px;
}
.siteHeader {
background: yellow;
n_height: 24px;
}
.siteHeader__logoArea {
min-width: 270px;
/* width: 270px; */
padding: 4px 8px;
background: green;
}
.siteHeader__splitter {
border: 1px solid blue;
width: 8px;
height: 24px;
}
.siteHeader__titleArea {
padding: 4px 8px;
background: green;
}

Chrome and Safari do not support the min-width property on table elements. They will, however, respect min-width when applied to table cells. You're applying display: table to the .htstackpanel div.

Related

Float: right causing element to pushed to next line in Firefox

I have four elements in a div. Out of them, I want the last element to be pushed to the extreme right. I am using float: right for the last element. This results in the last element to be pushed to the right end of the next line in Firefox. For other browsers, rendering is absolutely fine. I cannot make any modification in the HTML.
How can this be fixed?
IF you Share your Code ,I can Help you Better.But I have a few suggestions:
1)Use of width Property to all Elements.(Width's Element1 + Width's Element2 + Width's Element3 + Width's Element4 <= 100%)
2)Use of box-sizing:border-box Property to all Elements.
3)Use of float:left' For the first three elements and float:right` for last Element.
This is example :
.el1, .el2, .el3, .el4 {
width: 20%;
box-sizing: border-box;
border: 1px solid orange;
background-color: #000;
color: orange;
float: left;
}
.el4 {
float: right;
}
<div class="wrapper">
<div class="el1">Element1</div>
<div class="el2">Element2</div>
<div class="el3">Element3</div>
<div class="el4">Element4</div>
</div>
This Work For Me well,I Hope Work For You!
Check this fiddle here. This works fine in Firefox. Maybe you can adjust the CSS.
.container {
width: 100%;
height: 60px;
background-color: green;
}
.el {
width: 50px;
height: 50px;
background-color: red;
display: inline-block;
border: thin solid black;
}
.element4 {
float: right;
}
<div class="container">
<div class="el"></div>
<div class="el"></div>
<div class="el"></div>
<div class="el element4"></div>
</div>
This is a bug in Firefox itself.
https://bugzilla.mozilla.org/show_bug.cgi?id=488725
I have fixed it using firefox specific styles:
#-moz-document url-prefix() {
//your styles here
}

Trouble with divs?

Okay, I'm very new to CSS and only minimally familiar with HTML so I'm still kind of fumbling around with both of them. I'm building a practice site and I can't figure out what I'm doing wrong here. My goal is to have the image box to the left of the header and paragraph, but have the title on the same line as the top of the image. Here's what I have:
<img src="" />
<div class="bios">
<h4>First Last</h4>
<p>This is my bio</p>
</div>
Paired with this CSS:
.bios {
height: 100px;
width: auto;
display: inline;
background-color: #a78ffc;
clear: left;
display: inline;
/** top, right, bottom, left **/
margin: 1px 1px 1px 10px;
/** top, right, bottom, left **/
padding: 1px 1px 1px 10px
}
img {
height: 100px;
width: 100px;
float: left;
clear: left;
display: inline;
}
I added the background color to really see what's going on in the preview and I'm more confused than ever. This is how it's displaying:
http://i1126.photobucket.com/albums/l618/spenciecakes/Screen%20Shot%202016-05-13%20at%2010.41.45%20AM_zps50dajzko.png
EDIT
Okay, I've added the additional code as requested and I've added the display: inline to both elements but honestly it all appears the same..
I can't solve your problem with only the code you provided (what's the code for the images?), but I can tell you what's wrong with the current code. First, in order for the width and height property to work, the display property needs to be set to either inline-block or block.
Secondly, the float property does not have a value center. It can only take the values left and right (you need to the first one in this case).
The negative margin trick works like a charm (Explanation in code comments)
.bio {
overflow: hidden; /* Prevent negative margin from leaking out */
}
.bio-inner {
overflow: hidden; /* Clearfix */
margin-left: -1em; /* A) Remove spacing between items when they are against the left side (Must be negative B) */
}
.bio-thumbnail {
height: 3em;
width: auto;
background-color: #a78ffc;
}
.bio-thumbnail,
.bio-info {
float: left;
margin-left: 1em; /* B) Add spacing between items (Must be positive A) */
}
.bio-info-heading {
margin: 0em; /* Just removing default margins */
}
.bio-info-text {
margin-top: 0.5em;
}
<div class="bio">
<div class="bio-inner">
<img class="bio-thumbnail" src="http://i.stack.imgur.com/7bI1Y.jpg">
<div class="bio-info">
<h4 class="bio-info-heading">First Last</h4>
<p class="bio-info-text">This is my bio</p>
</div>
</div>
</div>
This, I have found, works best in cases where screens may be too small to fit the image and text side-by-side.
You can use display: inline-block.
.inline {
display: inline-block;
}
.title {
font-weight: bold;
}
<div>
<div class="inline">
<img src="http://placehold.it/50x50" />
</div>
<div class="inline">
<div class="title">Item 1</div>
<p>Item 1 description</p>
</div>
</div>
<div>
<div class="inline">
<img src="http://placehold.it/50x50" />
</div>
<div class="inline">
<div class="title">Item 2</div>
<p>Item 2 description</p>
</div>
</div>

Can't get "content" div to extend length of page

I have Googled this and tried all they suggested and it doesn't seem to be working.
I am making a template - so it all has to be in one HTML file. I am guessing something is screwy with my CSS that I'm just not catching... I've scanned it several times though.
Picture of problem (I want the white to extend to the bottom of the page; even if there isn't enough content):
CSS (there is more, but I figure these are the only ones that matter):
html, body
{
padding: 0px;
min-height: 100%;
margin: auto;
background-image: url("http://www.pixieduststudio.net/images/stripes.png");
background-repeat: repeat;
}
#wrapper
{
width: 80%;
margin: auto;
background-color: transparent;
}
#navbar
{
background-color: white;
text-align: center;
width: 100%;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
display: block !important;
margin: auto;
height: 75px;
}
#sidenav
{
width: 20%;
float: left;
border-bottom-left-radius: 5px;
border-right: 1px solid pink;
background-color: white;
}
#content
{
padding: 25px;
width: 80%;
float: left;
background-color: white;
margin: auto;
}
#content #pageTitle
{
margin: 0;
padding: 25px;
letter-spacing: 3px;
}
#pageContent, img
{
width: 80%;
}
HTML
<div id="wrapper">
<div id="navbar" class="navbar navbar-default" role="navigation">
<ul id="nav">
<!-- LINK ARE HERE BUT I REMOVED THEM -->
</ul>
</div>
<div id="sidenav">
<div id="socialBar">
<img src="http://www.pixieduststudio.net/images/facebook.png">
<img src="http://www.pixieduststudio.net/images/Instagram.png">
<img src="http://www.pixieduststudio.net/images/EmailUs.png">
</div>
<div id="shopBar">
<img src="http://www.pixieduststudio.net/images/shoppen.png">
<hr class="section">
<figure>
<img class="icon" src="http://www.pixieduststudio.net/images/bag.png">
</figure>
<img src="http://www.pixieduststudio.net/images/shopinfpen.png">
<hr class="section">
<div class="sidelinks">
<li>Meet Pixie</li>
<li>Shipping</li>
<li>Site Map</li>
<li>Order Tracking</li>
<li>Guest Chat</li>
</div>
<img src="http://www.pixieduststudio.net/images/searchpen.png">
<hr class="section">
<p style="margin: 25px;">%SEARCH_SITE%</p>
</div>
</div>
<div id="content">
<img id="pageTitle" class="img-responsive" src="http://www.pixieduststudio.net/images/headertitle.png" />
<hr>
%CONTENT%
<!--<p id="pageContent" style="padding: 25px;">
<img src="http://www.pixieduststudio.net/images/camp.png">
</p>-->
</div>
<div id="foot">
<!--<img src="images/footer.png">-->
</div>
</div>
You have to move background-color: white; to #wrapper, which is the container of both the content and the sidebar, to make the full box bg white.
Change #sidenav and #content to display: inline-block rather than float: left to allow #wrapper to adjust to the height of its contents. Add vertical-align: top so they will properly top-align to eachother.
#wrapper
{
width: 80%;
margin: auto;
background-color: white;
}
#sidenav
{
width: 20%;
display: inline-block;
vertical-align: top;
background-color: white;
}
#sidenav .nav {
border-bottom-left-radius: 5px;
border-right: 1px solid pink;
}
#content
{
padding: 25px;
width: 80%;
display: inline-block;
vertical-align: top;
margin: auto;
}
You'll also have to get rid of the 1px right border on #sidenav, which will make the contents of #wrapper add up to more than 100% of its with (and therefore wrap).
Change your sidenav content to:
<div id="sidenav">
<div class="nav">
...
</div>
</div>
In order to fix this, you can change the height of your container to use the vh unit
In your css, set the height of your main content container to:
#content
{
height: 100vh;
}
This will set the height of the container to 100% of the browsers vertical height in the viewport, please note this may have compatability issues with older browsers.
In the case of your problem, you will also need to set the parent elements height to 100vh too, this is because the child element (your main content) will fit to 100% of its parents height, which doesn't fit the whole page, to fix this, add the following to your css:
#wrapper
{
height: 100vh;
}
The child elements will now be able to fill the entire screen.
Consider the following example...
CSS
html,
*
{
border : 0;
box-sizing : border-box;
margin : 0;
padding : 0;
}
#wrapper
{
background-color : red;
display : flex;
min-height : 100vh;
}
#col-1
{
background-color : blue;
display : block;
float : left;
width : 25%;
}
#col-2
{
background-color : yellow;
display : block;
float : left;
width : 75%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport"
content = "width = device-width, initial-scale = 1.0"
>
<link href = "CSS/Example.css"
rel = "stylesheet"
type = "text/css"
>
<style>
</style>
</head>
<body>
<div id="wrapper">
<div id = "col-1">
<p>Column1</p>
<p>Column1</p>
<p>Column1</p>
</div>
<div id = "col-2">
<p>Column2</p>
</div>
</div>
</body>
</html>
The * section in the CSS file gets rid of any default borders, margins and padding for all elements unless they are subsequently specified. The box-sizing : border-box; line makes sure that any borders, margins and padding are contained within the specified width and height, which makes laying out a page much easier.
Please visit https://css-tricks.com/snippets/css/a-guide-to-flexbox/ for an explanation of flexbox.
Applying this structure to your page should solve the specified problem nicely.
If you have any questions, then please feel free to reply.

Element background color not displaying in IE

I have a page with 4 <div>'s that have float: left applied to them inside of a container element. The container has background: #ffffff applied to it, but it is not working as I would expect in IE (8, specifically). It works fine in Chrome and FireFox.
I know that if I remove my slider from the container, everything displays as I would expect it. So it has something to do with that, I'm just not sure what it is.
Here is how it should look:
Here is how it is displaying in IE:
CSS:
/* Container */
.main-content {
margin-bottom: 15px;
background: #ffffff;
border: 1px solid #e1e1e1;
}
/* Columns (Wrecked Vehicles, Welcome, Inv Search) */
.col {
float: left;
width: 289px;
padding: 10px;
margin: 5px;
}
/* Slider */
.slider {
float: left;
padding: 10px;
margin: 5px;
}
HTML:
<div class="main-content">
<div class="col n1">
...
</div>
<div class="slider">
...
</div>
<div class="col n2">
...
</div>
<div class="col n3">
...
</div>
<div class="clear"></div>
</div>
Try adding overflow:hidden to the .main_content. The reason the backgorund isn't showing is because, due to all the children floating, the container has zero "real" height.

IE 8 Overflow not rendering

I'm trying to add overflow to an HTML element, and of course it works in every browser but IE.
Here is my code:
<div class = "twitter">
<div class="twitter_image">
<div class="user"></div>
</div>
<div class="label">
<div class="boarder_control">
<div class= "tweet_container">
</div>
</div>
<div class ="smfooter"></div>
</div>
</div>
css:
.twitter {
padding-bottom: 2px;
background-color: green;
}
.smfooter {
padding: 2px;
height: 10px;
}
.label {
height: 15px;
}
.tweet_container {
overflow-y:auto;
}
.boarder_control{
padding:5px;
}
.tweet {
margin-top: 7px;
margin-bottom: 7px;
}
What are the best practices for using overflow with IE 8?
IE:
All other browsers on earth:
Thanks
http://www.w3schools.com/cssref/css3_pr_overflow-y.asp
Note: The overflow-y property does not work properly in IE8 and earlier.
You can resolve this by using overflow: scroll;
If there is a horizontal scroll bar then you may have to hide it with another div.
Try this thread...
Hide html horizontal but not vertical scrollbar
try to also assign an height to .tweet_container e.g.
.tweet_container { height: 300px; overflow-y: auto; }