Our nav bar images jump around on page refreshes, and we have no clue how to fix it. It only seems to occur when the page refreshes, suggesting that it's somehow related to the loading of our sprite (which contains all the images for the nav bar links)?
We have tried playing with different float values, rearranging our element layout, and many different alternatives. We still cannot get rid of the jumping. The other thing we have isolated is that the jumping is tied to the length of the text in the nav bar links, meaning that if we shorten the text labels under each image, the jumping is minimized.
This happens on iPads and also on Chrome on Windows 7 Home Premium and OS X 10.7.5.
Here's the HTML for the nav bar:
<div id="header">
<div class="main">
<a class="logo" href="/"><img class="" src="/images/web/logos/text_small.png" alt="Domain Name Registration and Search"></a>
<div class="nav_bar">
<a class="games icon_rise" href="/itunes-store/apps/free-apps/category/all-games?itunes-store-id=888-6014">
<div class="icon"></div>
<div class="label click_drop">Games</div>
</a>
<a class="education icon_rise" href="/itunes-store/apps/free-apps/category/education?itunes-store-id=6017">
<div class="icon"></div>
<div class="label click_drop">Education</div>
</a>
<a class="entertainment icon_rise" href="/itunes-store/apps/free-apps/category/entertainment?itunes-store-id=6016">
<div class="icon"></div>
<div class="label click_drop">Entertainment</div>
</a>
<a class="lifestyle icon_rise" href="/itunes-store/apps/free-apps/category/lifestyle?itunes-store-id=6012">
<div class="icon"></div>
<div class="label click_drop">Lifestyle</div>
</a>
<a class="music icon_rise" href="/itunes-store/apps/free-apps/category/music?itunes-store-id=6011">
<div class="icon"></div>
<div class="label click_drop">Music</div>
</a>
<a class="utilities icon_rise" href="/itunes-store/apps/free-apps/category/utilities?itunes-store-id=6002">
<div class="icon"></div>
<div class="label click_drop">Utilities</div>
</a>
<a class="all_apps icon_rise" href="/itunes-store/apps/free-apps/all">
<div class="icon"></div>
<div class="label click_drop">All Apps</div>
</a>
</div>
</div>
</div>
Here's the CSS:
#header { text-align:left; height:75px; background:url(/images/web/header_slice.png) repeat-x; }
#header .logo { position:relative; top:15px; width:106px; display:inline-block; }
#header .logo img { width:106px; height:35px; }
#header .nav_bar { width:720px; float:right; display:inline-block; position:relative; top:12px; text-align:right }
#header .nav_bar a { display:inline-block; margin-left:30px; max-width:100px; }
#header .nav_bar .icon { width:25px; height:25px; background:url(/images/web/nav_bar_icons.png) no-repeat; background-size:295px 70px; margin:auto; }
#header .nav_bar .games .icon { background-position:-45px 0 }
#header .nav_bar .education .icon { background-position:-90px 0 }
#header .nav_bar .entertainment .icon { background-position:-135px 0 }
#header .nav_bar .lifestyle .icon { background-position:-180px 0 }
#header .nav_bar .music .icon { background-position:-225px 0 }
#header .nav_bar .utilities .icon { background-position:-270px 0 }
#header .nav_bar .label { color:#00435d; font-size:15px; font-weight:bold; text-align:center; }
#header .nav_bar a:hover { text-decoration:none }
To reproduce:
1) Visit www.tekiki.com. The first time you visit, the nav bar links at the top will jump.
2) To reproduce the error, hit Shift-F5.
3) Attached is a screen shot of the nav bar links jumping.
This is due to font rendering on page load.
During page load, the 'Signika' font loads - overriding any fonts before it.
body, p, ol, ul, td {
font-family:'Signika', verdana, tahoma, arial, sans-serif;
}
Obviously, various aspects of the font/element change with a different font type/family. This font in particular, Signika, appears a lot larger than the fallback font Verdana.
Disable the 'Signika' font, so the fallback font is in action:
font-family:verdana, tahoma, arial, sans-serif;
You will see that 'jumping' nav appears (I see this in Chrome).
With the 'Signika' font in place, you can reduce the font size and/or surrounding margin and paddings to prevent this from happening.
The font-family you have loading called Signika is what causes the menu to jump.
If you want to keep the font-family and remove the jump then simply remove the width: 720px on #header .nav_bar. It is not required since it is floated, and the menu won't "jump".
Of course, because you are using a font that isn't available on a users computer the text will still change only as fast as the user downloads the font, but at least by removing the width property on the nav_bar you simply make it "slide" to the right.
Hope this helps.
i did this using fire bug see the changes hope it could help..
Related
img moved to bottom after float:right;
see to footer: http://qass.im/thestandard/
this footer code:
footer{
display:block;
margin:0 auto;
margin-bottom:50px;
width:800px;
height:100%;
clear:both;
}
.footer-content{
padding:80px;
padding-top:0;
padding-bottom:0;
}
footer p{
line-height: 1.714285714;
font-size:14px;
color:#555;
}
footer p a{
color:#555;
border-bottom:1px dotted #555;
}
.social-icon{
font-size:0;
float:right;
}
Do it this way.
The Code Changes:
<div class="footer-content">
<div class="social-icon">
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/twitter-footer.png"></a>
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/facebook-footer.png"></a>
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/google-footer.png"></a>
</div>
<p>
Powered by <a target="_blank" href="http://wordpress.org">WordPress</a> ©2013 The Standard, The Standard theme by <a target="_blank" href="http://qass.im/thestandard">Qassim.Dev</a>
</p>
</div>
This will make your image not to jump to the bottom.
They are rendered under the paragraph. As a p tag is block-level - so it occupies the full width.
What you can do:
variant 1: make .footer-content p {float: left;}
variant 2: change the order in your html. Make the div with a class of social-icon go before the paragraph.
delete the .social-icon's float
and use display:inline; for .social-icon and footer p
i have visited your page it isnt on the bottom because of float:right; (use a debugger - like firebug - and disable float:right; to check), its there because of the fact that it is a block element under another block element use display:inline-block; in your .social-icon and footer p css.
in conclusion
footer p{
display:inline-block;
}
.social-icon{
display:inline-block;
font-size:0;
float:right;
}
and BOOM! i did this in firebug on your site and it worked fine.
I have tried all sorts to find an answer to this, but what I want to do is have some text centered under two images.
I have tried using a turned into a line, but I cannot get the text to be under the centre of the image. Can any one help me ?
The web page is www.c5d.co.uk/captain.php
The HTML is:
<img class="social" src="http://www.c5d.co.uk/captain.png" alt="Captain">
<img class="socialtwo" src="http://www.c5d.co.uk/president.png" alt="President">
<div><ul class="captain"><li><p>John Lewis: Captain</p><p>Bill Wrigley: President</p> </li></ul></div>
<img class="social" src="http://www.c5d.co.uk/ladycaptain.png" alt="Lady Captain">
<img class="socialtwo" src="http://www.c5d.co.uk/juniorcaptain.png" alt="Junior Captain">
<div><ul class="ladycaptain"><li><p>Beryl Harrison: Lady Captain</p><p>Kieran Metcalf: Junior Captain</p></li></ul></div>
The relevant CSS is
.captain, .ladycaptain { /* ul - controls normal comp results& junior open*/
list-style-type:none;
display:table;
padding:0;
margin:0 auto;
}
.captain li, .ladycaptain li {
display:table-row;
text-align:left;/* ul - controls normal comp results& junior open*/
padding:0;
margin:0;
}
.ladycaptain p {
display:table-cell;/* ul - controls normal comp results & junior open*/
text-align:left;
padding:3px 10px 3px 0; /* padding-right visually separates "columns" */
}
.captain p {
display:table-cell;/* ul - controls normal comp results & junior open*/
text-align:left;
padding:3px 10px 3px 0; /* padding-right visually separates "columns" */
}
.ladycaptain p {
display:table-cell;/* ul - controls normal comp results & junior open*/
text-align:left;
padding:3px 20px 3px 0; /* padding-right visually separates "columns" */
}
.captain p + p {
padding-left:225px; /* padding-left visually separates "columns" */
}
.ladycaptain p + p {
padding-left:180px; /* padding-left visually separates "columns" */
}
Right now you have more HTML and CSS than you need, which is making your code harder to read and fix than it needs to be. Putting the text for each image in their own div will make it easier to center them, and be closer semantically to what you're trying to achieve. Then you can also use far less CSS to make it behave as you want.
Restructuring your HTML and CSS should do the trick:
<html>
<head>
<style>
#officers {
width:554px;
}
.officer {
width:267px;
position:relative;
float:left;
text-align:center;
margin:3px 10px 3px 0;
}
</style>
</head>
<body>
<div id="officers">
<div class="officer">
<img src="http://www.c5d.co.uk/captain.png" alt="Captain" />
<span class="caption">John Lewis: Captain</span>
</div>
<div class="officer">
<img src="http://www.c5d.co.uk/president.png" alt="President" />
<span class="caption">Bill Wrigley: President</span>
</div>
<div class="officer">
<img src="http://www.c5d.co.uk/ladycaptain.png" alt="Lady Captain" />
<span class="caption">Beryl Harrison: Lady Captain</span>
</div>
<div class="officer">
<img src="http://www.c5d.co.uk/juniorcaptain.png" alt="Junior Captain" />
<span class="caption">Kieran Metcalf: Junior Captain</span>
</div>
</div>
</body>
</html>
Remove the margin-bottom of the images.
Increase the height of the ul containing the text.
Set the line-height of that li ( or a group of 'em ) to that height. It will be perfectly centered. Well of course it will be centered vertically, if that's what you want to achieve. Otherwise just setting the text-align to center should do the trick.
Try something like this:
<ul>
<li>
<img class="img1" src="" alt="">
<div>image 1</div>
</li>
<li>
<img class="img2" src="" alt="">
<div>image 2</div>
</li>
<li>
<img class="img3" src="" alt="">
<div>image 3</div>
</li>
....
</ul>
with css
li
{
display: inline-block;
margin: 20px;
}
div
{
text-align: center;
}
Here's a LIVE DEMO
Suggested by #Rob Grzyb :
Try grouping the image and caption into a single container/div and centering the contents. It will be much easier to do if you can restructure the HTML.
Suggested by #Pow-Ian : jsfiddle.net/KV7zT
Edited by me : jsfiddle.net/KV7zT/1 or jsfiddle.net/KV7zT/2/
html
<div style='text-align:center;width:50%;float:left;'>
<img src="http://www.c5d.co.uk/president.png" alt="President" />
<div style="clear:both"> Text Goes Here</div>
</div>
css
.none-needed {css:not needed 'yet';}
I gave up ! and tried something different.
Just have a text spacing error now !
Thanks for all your suggestions
Antony
I have a top nav that extends across the page
Within that top nav I have various elements
two that must align left
one that must align right
The nav is fluid the elements are fixed widths
Do not want the elements to wrap when the browser window is minimized
Needs to work in IE6 on up due to high Chinese audience.
See example here:
http://jsfiddle.net/4SUwg/
<div id="header">
<div id="headerContent">
<div class="search-list"> Search List </div>
<div class="social-buttons"> Social </div>
<div class="signin"> Login Drop Down </div>
</div>
</div>
I would like the div elements within the nav to not wrap. I searched around on stack and could find answers that come close but nothing that completely addressed the issue. My need to have the div element aligned right complicates matters. Must work in all browsers, especially IE's.
Thanks all for your help in advance!!!
Use SPAN .. It's INLINE and not BLOCK ??
<div id="header">
<div id="headerContent">
<span class="search-list"> Search List </span>
<span class="social-buttons"> Social </span>
<span class="signin"> Login Drop Down </span>
</div>
</div>
And your CSS, remove floats
<style>
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:150px;
background:#039;
}
.social-buttons {
width:150px;
background:#060;
}
.signin {
width:200px;
background:#F00;
}
You want a fluid layout but the most important rule of a fluid layout is not to set a definite width of elements but you have set the width.
The CSS have a <style> tag, which is not required, probably you put it by mistake.
I have set the width of divs inside headerContent in percentage value. The CSS is
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:28%;
float:left;
background:#039;
}
.social-buttons {
width:28%;
float:left;
background:#060;
}
.signin {
width:28%;
float:right;
background:#F00;
}
Just changed the width value and on my browser it looked fine, better than the before version. Here's a fiddle http://jsfiddle.net/DeepakKamat/s52Hn/8/
I found a solution that works in all browsers, specifically IE6 on up since that was a requirement for this project. If you have something better that accomplishes the same thing please post! My sincere thanks to everyone who answered/helped.
<div id="header2">
<table id="headerContent2">
<tr>
<td id="left" valign="top">
<div id="leftWrapper">
<div class="search-list2">Search List</div>
<div class="social-buttons2">Social Buttons</div>
</div>
</td>
<td id="middle"> </td>
<td id="right" valign="top">
<div class="signin2">Login Drop Down</div>
</td>
</tr>
</table>
</div>
<style>
#header2 {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
}
#headerContent2 {
width:100%;
}
#headerContent2 td {
height: 32px;
padding:0;
margin:0;
}
.search-list2 {
width:150px;
float:left;
background:#039;
}
.social-buttons2 {
width:200px;
float:left;
background:#060;
}
.signin2 {
background:#F00;
float:right;
width:400px;
}
#leftWrapper {
width:400px;
}
#middle {
width:100%;
}
</style>
See Demo of it working here. Copy the code and try it out in all the IE's since JSfiddle does not work in all IE's.
http://jsfiddle.net/GtXKE/
I am trying to create a grid layout using tags and css. I need the grid system to hold four main blocks as portrayed in the image below. I have created a solution that works great in safari and chrome, but not so well in firefox as the titles overlap. Please see my code below, and maybe someone can see where I have gone wrong! I cant for the life of me find the problem.
HTML CODE:-
<div class="elements_wrapper">
<div id="element1">
<img class="align-image" src="img/image1"/>
<span class="element-title">Title</span>
<p class="element-explain">Main text goes here</p>
</div>
<div id="element2">
<img class="align-image" src="img/image2"/>
<span class="element-title">Title</span>
<p class="element-explain">Main text goes here</p>
</div>
<div id="element3">
<img class="align-image" src="img/image3"/>
<span class="element-title">Title</span>
<p class="element-explain">Main text goes here</p>
</div>
<div id="element4">
<img class="align-image" src="img/image4"/>
<span class="element-title">Title</span>
<p class="element-explain">Main text goes here</p>
</div>
</div>
CSS CODE:-
.elements_wrapper {
width:100%;
margin-left:-65px;
margin-top:110px;
padding-bottom:30px;
}
#element1{
position:absolute;
display:inline-block;
margin-left:30px;
padding-bottom:20px;
}
#element2 {
position:absolute;
display:inline-block;
margin-top:200px;
margin-left:30px;
padding-bottom:20px;
}
#element3 {
position:absolute;
display:inline-block;
margin-left:545px;
margin-top:200px;
padding-bottom:20px;
}
#element4 {
position:absolute;
display:inline-block;
margin-left:545px;
padding-bottom:20px;
}
.element-title {
font-family:helvetica, arial, serif;
color:black;
display:inline;
font-size:14pt;
font-weight:bold;
padding-top:15px;
}
.element-explain {
font-family:helvetica, arial, serif;
font-size:10pt;
float:left;
width:280px;
}
.align-image {
border: none;
float:left;
padding-right:15px;
}
My code works great in safari and chrome, but not that well in firefox, please help. Also, please let me know if the code I have already used is bad or needs changing to ensure cross browser compatibility. Thanks so much.
See the next example: http://jsfiddle.net/ZNSAX/2/
.element-explain {
font-family:helvetica, arial, serif;
font-size:10pt;
float:left;
width:280px;
}
Floating left here will cause this error. Firefox is a bit finicky with floating elements than Chrome and IE. Removing this should fix your problem.
I know there are several posts about this but none of the solutions are working for me. With that said, my containing div will not grow with my content. I know why this is happening, because it is 'float'ing but even when I use 'clear' it will not expand with the parent div. I've tried using using clear in nearly every element below with no success. Any help would be greatly appreciated.
View Image of problem:
For a live example please visit, http://thehopcompany.com/index.php?id=49
---------------CSS----------------
.product {
width:775px;
margin:0;
padding:0;
margin-top:75px;
margin-left:-8px;
}
.product ol{
margin:0px;
}
.product li{
list-style:none;
margin: 0 0 15px 0;
padding:15px;
border:1px solid #ccc;
height:100px;
color:#000;
}
.product-column-left{
float:left;
width:100px;
height:100px;
}
.product-column-right{
float:left;
width:120px;
border-left:1px solid #ccc;
height:100px;
text-align:center;
}
.product-column-center{
float:left;
width:470px;
min-height:100px;
padding-right:15px;
padding-left:15px;
text-align:left;
padding-bottom:30px;
display:block;
}
.product h2{
font-size:18px;
margin-bottom:5px;
margin-top:0;
}
.product .text-underline{
text-decoration:underline;
}
.description-text{
font-size:12px;
color: #000;
}
.clear{
clear:both;
}
--------------------------HTML--------------------------
<li style="list-style:none;">
<div style="width:750px;" >
<div class="product-column-left">
<img align="left" style="border:0;" src="images/hop-pellets.png" width="100" height="100" />
</div>
<div class="product-column-center" >
<h2><span class="hop-title-text-product">Columbus, Tomahawk and Zeus</span></h2>
<div class="description-text" >Proprietary naming rights sometimes have identical or nearly identical strains being sold under multiple names. Columbus, Tomahawk and Zeus, or the CTZ hops, are the most famous example of this phenomenon. CTZ hops are known as super-alpha hops due to the extremely high percentage of alpha acids they contain, making them ideal bittering additions. Columbus hops can be found alongside Centennial hops in Stone Ruination IPA or in Saranac's Brown Ale.
Proprietary naming rights sometimes have identical or nearly identical strains being sold under multiple names. Columbus, Tomahawk and Zeus, or the CTZ hops, are the most famous example of this phenomenon. CTZ hops are known as super-alpha hops due to the extremely high percentage of alpha acids they contain, making them ideal bittering additions. Columbus hops can be found alongside Centennial hops in Stone Ruination IPA or in Saranac's Brown Ale.
</div>
<div class="product-column-right">
<h2>$0.00</h2>
<img style="margin-top:10px; border:0;" type="image"src="images/add-to-cart-button.png" width="90" height="25" />
</div>
</div>
</li>
</ol>
</div>
Try to add overflow hidden to the parent li
.product li {
....
overflow: hidden;
/*height: 100px;*/
}
The problem with overflow:hidden is it will hide overflowing elements if you have them in your layout. So by using clearfix which is i suppose the best practice you can acheive it like below.
.clearfix:after {
content: " "; /* Older browser do not support empty content */
visibility: hidden;
display: block;
height: 0;
clear: both;
}
Then, basically you just need to add the class in your container elements. More about Clearfix
<li class="clearfix">
<div style="float: left;">
<div class="content">Big content</div>
</div>
</li>
FIDDLE DEMO
Adding a clearfix should solve your problem:
.clear{width: 100%; clear: both; height: 0px; line-height:0px;}
<div class='clear'></div>
.clear{width: 100%; clear: both; height: 0px; line-height:0px;}
<div class='clear'></div>
Add the above div at the very end of your container div (i think after product-column-right) and just before your closing li tag. That should ensure that the div spans the content.
Your product.li style has a height of 100px, so that's going to constrain the box no matter what. Remove that setting (or change it to height:auto) and then add an empty clear div just before the closing li tag and you should be fine.
So your CSS definition would change to:
.product li{
list-style:none;
margin: 0 0 15px 0;
padding:15px;
border:1px solid #ccc;
height:auto;
color:#000;
}
And then the relevant HTML:
<img style="margin-top:10px; border:0;" type="image"src="images/add-to-cart-button.png" width="90" height="25" />
</div>
</div>
<div style="clear:both"></div>
</li>
</ol>
</div>
I was using overflow: for a while with much success - but I had a few problems and decided to go back to this clear fix. If you have any problems - check it out.
http://css-tricks.com/snippets/css/clear-fix/