Chrome: inline-block, padding-right and right click bug - html

I am creating a CSS centered horizontal list for our team's site. It's unfinished, but here is a demo of how it looks so far: http://marbleblastultra.tk/welcomeguest.htm
In Firefox, the list looks how I intend it to look.
In IE, it's not perfect, but it's nothing that I can't fix later on.
However, in Chrome, the longer text is overflowing outside of the
items... until I right click on them...
or until I uncheck float-right in Chrome's inspector, then check it
again.
Such a weird, strange behavior. Right clicking? Why? Google searching reveals nothing. Searching this forum reveals nothing about the phenomenon either.
I am using Chrome 40 for Windows, but it might happen on different versions too.
What makes this list so complicated and unique is each item's background image. I want the text for each item to be centered both vertically and horizontally inside the background image. Easy enough, but the background images have transparent corners, and I need to use padding to push the text into the middle.
The above image shows how each item should look in the centered horizontal list, with the text centered within the blue area, never on top of the transparent corners (highlighted in green).
The above image, however, shows what I see instead in Chrome right now. The text incorrectly overflows outside of the box. Here is a cleaned up code sample from the test page.
CSS:
ul.welcomeguest li {
min-width:150px;
min-height:50px;
vertical-align:middle;
line-height:50px;
white-space:nowrap;
display:inline-block;
background:url(images/button_d.png) no-repeat center;
background-size:100% 100%;
}
ul.welcomeguest li div {
display:inline-block;
padding-left:10%;
padding-right:10%;
}
HTML:
<div style="width:100%" align="center">
<ul class="welcomeguest">
<li><div>Homepage</div></li><!--
--><li><div>Login/Register</div></li><!--
--><li><div>Download Game</div></li><!--
--><li><div>Download Levels</div></li><!--
--><li><div>View Leaderboards</div></li><!--
--><li><div>Info/Tutorials</div></li><!--
--><li><div>Contact Locations/About</div></li>
</ul>
</div>
How may I reliably add padding-right to a display:inline-block'd element in Chrome, if at all?
JSFiddle? http://jsfiddle.net/mh70zn34/3/

ul.welcomeguest li:last-child{
min-width: inherit;
}

I'm sorry :D, Please check it
HMLT : you need remove tag div in
<div style="width:100%" align="center">
<ul class="welcomeguest">
<li>Homepage</li>
<li>Login/Register</li>
<li>Download Game</li>
<li>Download Levels</li>
<li>View Leaderboards</li>
<li>Info/Tutorials </li>
<li>Contact Locations/About</li>
</ul>
</div>
and css:
body {
background-color:#EEEEEE;
}
ul.welcomeguest li a {
min-width:150px;
min-height:50px;
vertical-align:middle;
line-height:50px;
white-space:nowrap;
float:left;
background:url(http://marbleblastultra.tk/images/button_d.png) no-repeat center;
background-size:100% 100%;
padding:0 20px;
}
.welcomeguest li {
display: inline-block;
list-style: outside none none;
overflow:hidden;
}
http://jsfiddle.net/mh70zn34/11/
Note: Can't use padding with percent value in your layout.

Related

display: inline-block; issue on Firefox

I have with inline-block property in Firefox and probably in IE also. I am expecting the same result as I am getting in Chrome.
Chrome desktop screenshot
Chrome and Firefox tablet (I have to keep "A" and "BC" together in tablet view)
Here is a problem with Firefox desktop view. As you can see E is not visible in screenshot. I google it but did not find the solution. JSFiddle
HTML
<div class="text-center">
<div class="text">
<div class="col-first">A</div>
<div class="col-last">
<ul class="links">
<li>B</li>
<li>C</li>
</ul>
</div>
<div class="col-middle">
<ul>
<li>C</li>
<li>D</li>
<li>E</li>
</ul>
</div>
</div>
</div>
CSS
ul{ margin:0; padding:0; list-style:none}
.text-center{text-align:center}
.text{ display:inline-block}
.col-first {
float: left;
padding-right: 20px;
}
.col-last {
float: right;
}
.col-middle {
overflow: hidden;
white-space: nowrap;
}
.social li{float:left}
.col-middle li{ display:inline-block; padding:0 17px}
#media(max-width:768px){
.col-first {float:none;display:inline-block; padding-right:10px; vertical-align:top}
.col-last {float:none;display:inline-block}
.col-middle { width:100%}
}
You can see what is going on if you mess around with column width.
Essentially, is being created by the browser at one width (in my case:142px and the content inside of that div works out to be about 182px), so the browser is "tucking the E off of the page" because it won't fit in the space allotted for it.
This div size issue is caused because the size of div is determined when chrome loads, and is not checked again by chrome. You can see this by making your chrome width very large(zoom way out with the browsers functionality) and then refresh the browser. Your e will appear as desired, but if you make your browser narrower, and the wider again, the media query will reset the size of that div, and it will not get set back making the div disappear.
You can fix this by setting the width of to be greater(or equal to) using a relative width(eg .text{ display:inline-block;width:30%;}) or changing the list structure.

Proper way to layout anchor, image and div

I have a outer container, containing two links. They are aligning horizontally. The first one contains a div with background image and the second one is just text. The problem is the whole outer container acts as the first anchor, links to the first url while it is supposed to link nothing. Here's the simplified layout
<div id="links-block">
<div id="edit-quote-button"></div>
Preview the PDF
</div>
Here is the example JSFiddle. I am just wonder how to structure this set of elements, to prevent this problem.
Define this css
a{display:inline-block;vertical-align: top;}
#preview-pdf-link {
float: right;
margin-top: -30px; // remove this line
color: #999999;
}
Demo
here is your new html structure
<div id="links-block">
<a class="g-link" href="http://www.google.com"><div id="edit-quote-button"></div></a>
<a class="y-link" href="http://www.yahoo.com" id="preview-pdf-link">Preview the PDF</a>
<div class="clear"></div>
</div>
add this css to your css file
.g-link{
display:block;
float:left;
}
.y-link{
display:block;
}
.clear{
clear:both;
height:0px;
width:0px;
display:block;
}
hope this will work for you
It's not a great idea to have a div inside the a like that (invalid in pre-HTML5). If you set the edit-quote-button div to display: inline-block it will work better, though. Then remove the negative top margin on the Yahoo link.

Wordpress: Extra space below the footer

I have read a lot of answers regarding this but it does not solve my problem. On the main page when I scrolled to the bottom, the footer has an extra space but it seems like the extra space below it is the background of my page. In other pages, the footer is okay. I think this happened because my main page has a short content. I actually cheated on its sidebar by adding margin bottom. Any help which applies to all browsers and any screen sizes that will fix this? Thanks!
This is the CSS of my footer:
#footerArea{
height:108px;
width:100%;
z-index:5;
background:url('../images/footerArea.jpg') #404042;
}
#footerPart{
height:48px;
width:988px;
margin:0 auto;
padding:0px;
background:url('../images/footerbg.jpg') no-repeat #404042;
}
#footerPart a {
text-decoration:none;
}
#footerLink{
margin:0 auto;
padding:15px 0px 0px 0px;
width:960px;
}
#footerLink ul{
list-style-type:none;
float:left;
}
#footerLink ul li{
display:inline;
margin:0px 5px 0px 0px;
}
#footerLink ul li a{
background:url('../images/footerbtn.jpg') no-repeat;
font-size:10px;
text-decoration:none;
padding:0px 0px 0px 15px;
}
EDITED:
This is from footer.php
<div id="footerArea">
<div id="footerPart">
<div id="footerLink">
<ul>
<li>xxx</li>
<li> | </li>
<li><li>yyyy</li>
<li> | </li>
<li>zzzzz</li>
<li> | </li>
<li>aaaaaa</li>
</ul>
<p class="fR">SOME TEXT ggggg</p>
</div>
</div>
</div>
</body>
</html>
I have tested it in Chrome, Firefox and IE but it has the same output.
Check if you have some kind of web tracking code or any other javascript (in javascript tags) at end of your document. Though it must be a few lines of javascript code, it sometimes takes-up space beneath footer in some browsers, especially in IE. If you can provide a codepen reference, we can review
In your HTML you have a <li> tag embedded within another <li> which is invalidating your code, as it doesn't have a closing tag.
Short of that, it's hard to debug such a vague problem as "Has extra space". To provide further insight it would be great if you could provide a jsfiddle or something similar.
If you can't provide that or don't know how, I can offer some debugging tips. If you're using google chrome to debug, you can go into your webkit inspector, or firebug if using firefox (Right click, "inspect element") and look at the CSS and boxing for paticular elements.
If that fails and you still can't figure out what's causing the extra space, you can right click elements and begin deleting the ones that you think may be the root of the problem. Once an element is deleted it will no longer appear in your browser, so if you delete one and the problem persists, you can be comfortable knowing it wasn't that element (or is multiple elements, but lets not get that complex.)

Vertical align text with icon

I've a text as below is not aligning as vertical in the middle of icon.
How do I solve this, please?
align top http://www.kerrydeaf.com/ali.png
CSS:
#text{ color:#48c4d2; font-size:15px; font-family:opensansitalic;}
HTML:
<div class="blurb"><button class="blue_small" id="blue_small"></button> Available in video.</div>
UPDATE:
This should explain it.
align top http://www.kerrydeaf.com/ali2.png
You should be using a CSS background image and use padding-left: to move the text over, and use background-position: to adjust the position of the image. And if it's a link, use an A-tag, not a button.
Available in video.
No need to nest tags as you're doing.
Something like:
.videoBlurb {
display:block;
background-image:url(....);
background-repeat:no-repeat;
background-position:0px 0px;
padding-left:40px;
padding-top:20px;
color:#48c4d2;
font-size:15px;
font-family:opensansitalic;
}
Diodeus makes a good point and definitely has the most useful answer, but for the sake of curiosity without changing your markup - it should actually be this simple:
​button {
vertical-align:middle;
}
Of course, be more specific with the selector. Demo: http://jsfiddle.net/beV7j/2

UL - LI Bullets as Image an right side next to the text

i have some problems with styling an UL as navigation bar (sorry for this question, but iam a developer, not designer..)
The Problem occours in Safari on Mac (FF is working fine) See first picture (FF)
Css:
.multiPoint {
list-style-image:url(../images/punkte.jpg); }
.directionRight{
direction:rtl;
padding-right:3em;
margin-right:0.5em;
}
#navigation {
text-align: left;
}
HTML:
<div id="navigation" class="span-6 directionRight">
<ul>
<li class="multiPoint">Sie</li>
</ul>
</div>
If the bullet image is directional (like in the example above), the rtl approach may have the unintended side-effect that the image is mirrored in some browsers, resulting in an arrow pointing from right to left instead of left to right.
A background image does not show this behavior in IE9 and it maintains the correct orientation.
list-style: none;
background: url(images/bullet.gif) no-repeat center right;
padding-right: 10px;
Try updating your multiPoint class style as follows:
.multiPoint {
list-style-image:url(../images/punkte.jpg);
list-style-position: inside;
}
That will tell the browser to position your bullet images inside the list instead of outside.