Difficulty creating a content grid layout using css and html - css

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.

Related

CSS element doesn't show up in Chrome, but does on Firefox

I'm very new to all of this CSS business, so please forgive me if I'm missing something obvious. I'm using the 960.gz grid system to create a site at www.locodingo.com
I'm having an issue getting a light grey box (adBox in my CSS code) to show up on the right side of my website in Chrome underneath my menu, but it loads just fine in Firefox and Internet Explorer. I've messed with what seems like pretty much every variable but just can't get it to show. Please help!
* {
font-family:Arial, Verdana, sans-serif;
color:black;
}
#header {
background-color:#d3d3d3;
height:90px;
border-radius:10px;
position:absolute;
}
#header #logo {
height:80px;
padding:5px;
}
#nav li {
color:#F58535;
background-color:white;
float:right;
position:relative;
top:-99px;
right:0px;
text-align:left;
display:inline;
padding:7px;
font-weight:bold;
margin-right:15px;
border-radius:5px;
}
#nav2 li {
color:#6ABD50;
background-color:white;
position:relative;
display:inline-block;
float:right;
top:32px;
padding:7px;
font-weight:bold;
margin-right:15px;
border-radius:5px;
right:10px;
}
#nav li:hover {
background-color:#F58535;
color:white;
}
#nav2 li:hover {
background-color:#6ABD50;
color:white;
}
#adsBox {
height:250px;
background-color:#F2F3F3;
margin-top: 50px;
clear:right;
border-radius:10px;
display:inline-block;
}
#adsBox p {
margin:5px;
text-align:justify;
}
#footer {
position:relative;
background-color:black;
color:#F58535;
font-weight:bold;
font-family:sans-serif;
font-size:12px;
text-align:center;
height:20px;
clear:both;
}
bodyText{
right:122px;
position:relative;
float:left;
color:red;
display:block;
}
<div class="container_12 clearfix">
<div id="header" class="grid_12">
<img id="logo" src="images/logo.png"/>
<div id="nav">
<ul>
<li>Contact Us</li>
<li>Message Board</li>
<li>Opinion</li>
<li>Articles</li>
</ul>
</div>
</div>
</div>
<div id="nav2">
<ul>
<span><li>Cosplay</li></span>
<span><li>Tattoos</li></span>
<span><li>Music/Art</li></span>
<span><li>Recipes</li></span>
</ul>
</div>
<div class="container_12 clearfix">
<div id="bodyText" class="grid_8"><p>Just safdsfdadfafdfdome random stuff here.ust safdsfdadfafdfdome random stufust safdsfdadfafdfdome random stufust safdsfdadfafdfdome random stufust safdsfdadfafdfdome random stufust safdsfdadfafdfdome random stufust safdsfdadfafdfdome random stuf adggdadgsagddgsdsgagsd</p></div>
<div id="adsBox" class="grid_4"><p>Test text here est text hereTest text here est text hereTest text here est text hereTest text here est text hereTest text here est text hereTest text here est text hereTest text here est text hereTest text here est text here</p>
</div>
</div>
Do you have AdBlockPlus or any kind of adblocker extension in Chrome? If so, it's probably hiding that block based on its id.
jack was able to answer my issue for me. It was indeed AdBlockPlus blocking the div container because it was called "adsBox" and contained the word "ads". I feel pretty stupid - I guessthis is just one of those stupid little things I've got to learn about on my journey.
So, for future reference - don't name any container with the word "ads" in it.
Thank all of you for helping me out. Each and every one of you had valuable information that I'll be able to use.

aligning to div's next to each other - media query

I am trying to render a section of my pafe as in this following image. http://i.imgur.com/63q9Syr.jpg> I can now get it to render right in larger screens. But when I use meduia query the second box mis aligns. I appears to be a little above first box. Is there way I can fix it?
<section class="carousel price-carousel"> <!--Price section -->
<div class="container">
<div class="price-container">
<span class="month-column">
<h4>Monthly</h4>
<p>$9.95</p>
<p class=”sub-text”>per computer</p>
</span>
<span class="year-column">
<h4>Yearly</h4>
<p>$99</p>
<p class=”sub-text”>Save 20% when you pay anually</p>
</span>
</div>
</div>
</section>
Any help is much appreciated.
JSFiddle link: http://jsfiddle.net/d4gyo5s8/7/
Just delete:
margin-top:35px;
of set it to 0, in your media-query.
Also add:
vertical-align: top;
Proof:
http://jsfiddle.net/zmqoz7pv/1/
I've created a sample, check the below code and the fiddle sample!!
The HTML:
<section class="carousel price-carousel">
<div class="container">
<div class="price-container">
<span class="month-column">
<h2>Monthly</h2>
<h3>$9.95</h3>
<p class="sub-text">per computer</p>
</span>
<span class="year-column">
<h2>Yearly</h2>
<h3>$99</h3>
<p class="sub-text highlight">Save 20% when you pay anually</p>
</span>
</div>
</div>
</section>
The CSS
*, ht, h2, h3, h4, p, div, img {
margin:0;
padding:0;
}
.container {
background-color: #eee;
}
.price-container {
text-align:center;
vertical-align:top;
font-family:arial;
font-size:14px;
color:#333333;
}
.price-container span {
display:inline-block;
margin:10px;
padding-bottom:10px;
border:1px solid #676767;
width:300px;
background:#fafafa;
}
.price-container h2 {
font-size:18px;
font-weight:bold;
color:#f1f1f1;
background:#676767;
padding:5px 0;
}
.price-container h3 {
font-family:'Arial Black', Helvetica, Verdana, sans-serif;
font-size:30px;
font-weight:bold;
color:#000000;
padding:8px 0;
}
.sub-text {
font-family:arial;
font-size:16px;
}
.highlight {
color:#609347;
}
Fiddle Demo

css footer background didn't shows properly in html5

Here is my css code:
.footer{
clear:both;
background:url('../img/footer-bg.jpg');
overflow: hidden;
}
.footer-left{
float:left;
width: 50%;
}
.footer-right{
float:right;
width:50%;
}
.footer-nav .list-1 {
font-size:13px;
font-weight:600;
text-align: center;
}
.footer-nav .list-2 {
font-size:12px;
font-weight:600;
text-align: center;
}
.footer-nav ul li{
display:inline;
padding:8px;
}
.copyright{
font-size:13px;
text-align: center;
}
Here is my JSfiddle link: http://jsfiddle.net/3jet0dfu/12/
May i know how to set background image to 100% attached with window screen.and the footer content need to display right of image.
Now i added <hr /> line for footer-left and footer-right at the top and bottom.
But it shows at the top only, Can anybody help me exact css style to fix this.
I need look like this http://s30.postimg.org/gvqtdrmqp/article_page4.jpg.
Thanks in advance.
add to css
header,section{
margin:0 auto;
width:939px;}
and edit body css like this
body{
font-family: Raleway, sans-serif;
}
this working page jsfiddle
remove the 2 and replace the following html and add the css
<div id="footer-holder">
<div class="footer-left">
<img src="http://s18.postimg.org/itr24b7s9/footer1.png" alt="footer-image" />
<div class="footer-content">
<p class="footer-title">.NET Training</p>
<p class="footer-pgf">Less of boring theory! Hands on programming is our training methodology! You'll love it.<p>
learn more
</div>
</div>
<div class="footer-right">
<img src="http://s18.postimg.org/gl8a98bah/footer2.png" alt="footer-image" />
<div class="footer-content">
<p class="footer-title">Shopify Expert at $20/hour</p>
<p class="footer-pgf">Unique custom made shopify theme and tweakss. Strat selling online with stunning eCommerce storefronts created using the Shopify CMS</p>
learn more
</div>
</div>
<div style="clear:both"></div>
</div>
#footer-holder{
-webkit-border-image:url(border.png) 30 30 round; /* Safari 3.1-5 */
-o-border-image:url(border.png) 30 30 round; /* Opera 11-12.1 */
border-image:url(border.png) 30 30 round;
border-left:none;
border-right:none;
width: 100%;
}

Nav bar images jumping on page despite different CSS and HTML settings

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..

Why does the background of my container/wrapper not extend behind all content

Im working on a portfolio for uni and the background of my container / wrapper does not extend vertically enough in order for all its content to have a back ground color. I'll post code below, any help would be appreciated.
HTML
<body>
<section id="wrapper">
<header>
<hgroup class="title">
<h1>Matt Murphy</h1>
<p>Personal Portfolio | University of Leeds | BA New Media</p>
</hgroup>
</header>
<nav>
Home
About Matt
</nav>
<section id="modules">
<h2>Modules Studies To Date</h2>
<section id="year_1">
<h3>Year 1</h3>
<p>History of Communications</p>
<p>Academic Skills and Contemporary Issues</p>
<p>Interface Design</p>
<p>Design For New Media</p>
<p>Basic Camera and Editing</p>
<p>Animation For New Media</p>
</section>
<section id="year_2">
<h3>Year 2</h3>
<p>Dynamic Web Programming</p>
<p>Communications Research Methods</p>
<p>Working in New Media/p>
<p>Media Policy</p>
<p>New Media Narrative and Gaming</p>
<p>Visual Communications</p>
</section>
</section>
</section>
</body>
CSS
body{
color:#000;
background-image: url(images/canvas.png);
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
a:link {
text-decoration:none;
color:#000;
}
a:visited {
text-decoration:none;
color:#000;
}
a:hover {
text-decoration:none;
color:#000;
}
a:active {
text-decoration:none;
color:#000;
}
#wrapper {
background-color:#FFF;
padding:3%;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
display:block;
margin:auto;
width:60%;
margin-top:2%;
}
header {
text-align:right;
}
#modules {
width:100%;
display:block;
margin:auto;
}
#year_1 {
float:left;
}
#year_2 {
float:left;
}
To fix your problem you just need to add overflow: auto to #wrapper.
#wrapper {
background-color:#FFF;
padding:3%;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
display:block;
margin:auto;
width:60%;
margin-top:2%;
overflow: auto; /* add this line */
}
However, another issue is that you are using HTML5 elements and the HTML5 shiv but you have not used the HTML5 doctype:
<!DOCTYPE html>
I assume you are having problems in IE? You are missing a doctype declaration. If you add a transitional doctype as per the example on W3Schools below it should work.
HTML doctype declaration
Basically the css-property 'float' on the section#year is the bad guy here.
If I replace your sections with div's and add an extra div to clear block rendering it works:
http://jsfiddle.net/hoedinie/537sL/1/

Resources