This is my site in question: LINK
As you can see, my Logo is pushed over to the right side in Firefox but it should be centered. Works great in Chrome for example.
I've tried looking for a Firefox only stylesheet, but I couldn't really find the right CSS setting that makes this work correctly.
Here's the relevant HTML code that's wrapped in a id named container that I have so far:
<div id="nav">
<ul id="index_cards">
<li id="card-1">
<h3><strong>Home</strong></h3>
</li>
<li id="card-2">
<h3><strong>About/Contact</strong></h3>
</li>
<li id="card-4">
<h3><strong>Portfolio</strong></h3>
</li>
<li id="card-5">
<h3><strong>Services</strong></h3>
</li>
</ul>
</div>
<div id="header">
<div id="logo">
<img src="imgs/logo.png" name="ielogo" width="457" height="223" id="ielogo" />
</div>
</div>
CSS:
#container {
top:-73px;
margin-top:-70px;
min-height:100%;
position:relative;
display:block;
}
#header {
margin-top:-30px;
height:250px;
background-image:url(../imgs/header-top.png);
background-repeat:repeat-x;
padding:10px;
}
#logo {
margin:0 auto;
width:457px;
height:223px;
}
Problem lies with image put this in css
#logo img { display: block; }
http://jsbin.com/afuquq/3/
Revised answer: The solution is to incorporate the logo into the navigation section and have #header placed with position:absolute; on webpage.
HTML Fragment:
<div id="header"></div>
<div id="container">
<div id="nav">
<ul id="index_cards">
<li id="card-1">
<h3><strong>Home</strong></h3>
</li>
<li id="card-2">
<h3><strong>About/Contact</strong></h3>
</li>
<li id="card-4">
<h3><strong>Portfolio</strong></h3>
</li>
<li id="card-5">
<h3><strong>Services</strong></h3>
</li>
</ul>
<div id="logo"></div>
</div>
<!-- continued-->
</div>
CSS:
/* This section is modified */
#header {
background-image:url(http://tubebackgrounds.co.uk/portfolio/imgs/header-top.png);
background-repeat:repeat-x;
position: absolute;
width: 100%;
height: 250px;
margin-top: 40px;
}
/* This section is modified. */
#logo {
background-image:url(http://tubebackgrounds.co.uk/portfolio/imgs/logo.png);
background-repeat:no-repeat;
margin:0 auto;
width:457px;
height:250px;
}
There is also extra addition of margin-top: -20px; applied to CSS Selector #body to compensate for separate #font-face issue when those fonts are not loaded. Still, font integration will need to be addressed correctly.
Note: The jsFiddle below will not render #font-face fonts due to security settings.
Reference: jsFiddle
Access the above jsFiddle without /show/ in Address Bar to view the Edit Page.
Related
This is my code at the moment. I want it to produce a navigation bar with the image and text next to it on the same line on the far left (which it does) and all the menu items which are in the class="top_info" on the same line except they are pulled a bit to the right. Can someone help me?
<!DOCTYPE html>
<html>
<head>
<style>
body {background: ; margin: ; }
#container {width: ; margin:; background: #333300 ; }
#header {color: white;}
#logo { font-size: 18pt;}
#logo img {float: left ;}
#logo span {color:orange; }
.top_info {float:left; color:white;}
</style>
</head>
<body>
<div id="container">
<!--header-->
<div id="header">
<div id="logo"><img src="http://www.townplanning.com.au/app/theme/default/design/images/header/logo.png"><span>TOWNPLANNING</span>.COM.AU</p></div>
<div class="top_info">CONTACT US</div>
<div class="top_info">BLOG</div>
<div class="top_info">NEWS</div>
<div class="top_info">PREVIOUS VCAT DECISIONS</div>
<div class="top_info">PLANNING SCHEMES</div>
<div class="top_info">WHAT IS TOWN PLANNING?</div>
<div class="top_info">MAP</div>
<div class="top_info">ABOUT</div>
<div class="top_info">HOME</div>
</div> <!--div header end-->
</div> <!--DIV CONTAINTER end-->
Assuming that the logo and the text should be in first line and menu
should be in the second line, i have edited the code.
Please see the fiddle:DEMO
HTML:
<div id="container">
<!--header-->
<div id="header">
<div id="logo"><img src="http://www.townplanning.com.au/app/theme/default/design/images/header/logo.png"/><span>TOWNPLANNING</span>.COM.AU</div>
<ul class="top_info">
<li >CONTACT US</li>
<li >BLOG</li>
<li >NEWS</li>
<li >PREVIOUS VCAT DECISIONS</li>
<li >PLANNING SCHEMES</li>
<li >WHAT IS TOWN PLANNING?</li>
<li >MAP</li>
<li >ABOUT</li>
<li >HOME</li>
</ul>
</div> <!--div header end-->
</div> <!--DIV CONTAINTER end-->
CSS:
#container { margin:0; background: #333300 ;overflow:auto; }
#header {color: white;}
#logo { font-size: 18pt;}
#logo img {float: left ;}
#logo span {color:orange; }
ul{padding:0;}
.top_info li{ color:white;}
ul li{display:inline-block;list-style:none;}
It is always best practice to create menu's using ul li. and styling
them to display:inline-block which will make them appear in single
line.
I have applied the class to the ul tag , repeating it so many times
in a div is not good practice.
2.Assuming that the logo and the menu should be in the same line,
Please see the fiddle for that: DEMO
CSS:
#container { margin:0; background: #333300 ; overflow:auto; }
#header {color: white;}
#logo { float:left;font-size: 18pt;}
#logo img {float: left ;}
#logo span {color:orange; }
.top_info li{ color:white;}
ul li{display:inline-block;list-style:none;}
Well, I coded this page, but I got stuck at why does the third column is pushing down my text (or other elements). It uses the same style from the first box, but while the first box is ok, the third one is pushing the elements down by some pixels.
Like this:
HTML
<div id="contentWrapper">
<div id="sideBar">
<div class="sidebarBox"></div>
<div class="sidebarContent">
<h4>
Índice
</h4>
<ul class="tree">
<li>
Sinopse
</li>
<li>
Tropas
</li>
<li>
Geladeira
<ul>
<li>
Lógica
</li>
<li>
Gênio
</li>
<li class="last">
Horror
</li>
</ul>
</li>
<li>
Notas
</li>
<li>
Mídia
</li>
<li class="last">
Referências
</li>
</ul>
</div>
</div>
<div id="mainBody"></div>
<div id="infoBar">
<div class="sidebarBox"></div>3º Column
</div>
</div>
CSS
* {
margin:0;
padding:0;
font:normal normal 14px/20px Helvetica,Arial,sans-serif
}
h4 {
font-size:14px;
font-weight:700;
text-transform:uppercase;
padding-top:10px;
border-bottom:2px solid #2a558c;
margin-bottom:10px
}
#contentWrapper {
display:table;
border-spacing:0;
width:100%;
height:500px
}
#contentWrapper > div {
display:table-cell
}
#sideBar {
background-color:#E4E5DD;
width:200px
}
#mainBody {
background-color:#EEEEE6
}
#infoBar {
background-color:#e4e5dd;
width:200px
}
#footer {
background-color:#323540;
height:50px
}
.sidebarBox {
background-color:#323540;
height:30px;
width:100%
}
.sidebarContent {
padding:15px
}
I messed a lot with the Firebug and even tried to open it in IE and Chrome, with same results. Both columns use the same CSS, and this difference is freaking me out. I thought about "fixing" it with some negative margins, but I want to understand the problem first, insted of "workahacking" away.
Thanks a lot in advance!
Add vertical-align: top to #contentWrapper > div. Currently it is baseline.
Have a fiddle!
CSS
#contentWrapper > div {
display: table-cell;
vertical-align: top;
}
Without vertical-align: top, the div is basing its vertical alignment on .sidebarContent which has 15px of padding. This is resulting in the 15px gap.
Change the following and it should fix your problem. I've found that when using display:table-cell it always mis-aligns the last cell unless I specifically give it a vertical alignment
#contentWrapper > div {
display: table-cell;
vertical-align:top;
}
Example
Add display:inline-block to this class:
.sidebarBox {
background-color: #323540;
height: 30px;
width: 100%;
display: inline-block;/*Add this*/
}
fiddle
.sidebarBox {
float:right;
}
will work.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm not really good with CSS and html when the layout is complicated. I can quick fix things, but I have no real knowledge.
I'm trying to adapt this demo : http://demo.marcofolio.net/bgimg_slideshow/ for my website.
Problem: the logo is a background image for a div and not a link.
I'm not good enough to see how i could change it without defacing the layout.
Could you help me either by providing the fix (if it doesn't take you more than 5 minutes) or by giving me hints or links so i could figure it out myself?
Edit : here's a jsfiddle with minimum code
And here are the files :
html :
<div id="header">
<div id="headerimgs">
<div id="headerimg1" class="headerimg"></div>
<div id="headerimg2" class="headerimg"></div>
</div>
<div id="nav-outer">
<div id="navigation">
<div id="menu">
<ul>
<li>Marcofolio</li>
<li>Twitter</li>
<li>RSS</li>
<li>jQuery</li>
<li>CSS</li>
<li>Advertisements</li>
</ul>
</div>
</div>
</div>
</div>
Css :
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input{margin:0; padding:0;}
#header { height:600px; }
.headerimg { background-position: center top; background-repeat: no-repeat; width:100%; height:600px; position:absolute; }
#nav-outer { height:110px; padding-top:11px; position:relative; top:24px; background-image:url("http://demo.marcofolio.net/bgimg_slideshow/images/headerbg.png"); }
#navigation { height:100px; width:960px; margin:0 auto; background-image:url("http://demo.marcofolio.net/bgimg_slideshow/images/logo.png"); background-position:top left; background-repeat:no-repeat; }
#menu { position:relative; top:85px; }
#menu ul { list-style:none; }
#menu ul li { display:inline; font-variant:small-caps; font-size:12px; }
#menu ul li a { color:white; text-decoration:none; font-weight:bold; padding-right:20px; }
#menu ul li a:hover { text-decoration:underline; }
You should add
<div id="logo">
<a href="#">
<img src="images/logo.png" alt="" />
</a>
</div>
to <div id="#navigation">, right before <div id="search">
Then:
1) you should float the logo to the left
#logo{
float: left;
}
2) remove top: 85px; from #menu and add clear: both;
3) remove background-image: url("../images/logo.png"); from #navigation
This way, you have clickable image logo. :)
Explanation:
You float the logo to the left because #search is floated to right
You remove top: 85px; because that was compensation for empty space which is now filled with image, and add clear: both because it clears the floats and positions the menu back in place
Here is how I did it.
First, Remove the background image from your #navigation div.
Then add the following as a first child of the #navigation.
<a href="/" style="
height: 80px;
width: 500px;
background-image: url('http://demo.marcofolio.net/bgimg_slideshow/images/logo.png');
background-position: top left;
background-repeat: no-repeat;
display: inline-block;
position: absolute;
" alt="Image Description"></a>
So your Navigation div should look like this:
<!-- Remove all background attributes from #navigation in the CSS -->
<div id="navigation">
<!-- Below is the new line!, makes your logo clickable! -->
<a id="logo" href="" style="height: 80px; width: 500px; background-image: url('http://demo.marcofolio.net/bgimg_slideshow/images/logo.png'); background-position: top left; background-repeat: no-repeat;display: inline-block; position: absolute;"></a>
<!-- Everything else below stays the same!... -->
<div id="search">
<form>
<input type="text" id="searchtxt">
<input type="submit" value="search" id="searchbtn">
</form>
</div>
<div id="menu">
<ul>
<li>Marcofolio</li>
<li>Twitter</li>
<li>RSS</li>
<li>jQuery</li>
<li>CSS</li>
<li>Advertisements
</li></ul>
</div>
</div>
Basically, you make a <a href> which has a background image (all a href's are clickable). When you assign a background image to a <a href>, you have to set the display:block for it to be rendered as a block level element. In this case, we position it absolutely to knock it out of the document flow and keep it from disturbing other elements.
There are better ways to do this, but it would probably require re-writing some of your code (Which is not that difficult, but does require an amateur skill level of HTML & CSS).
Hope this helps!
I did some live edits on the link you provided. I think this is what you want to achieve.
Here is a Demo, based on your fiddle.
HTML
<div id="navigation">
<h1 id="logo">My Website!<br />
<span>loving jQuery and CSS</span>
</h1>
...
CSS
#navigation {
position: relative;
}
#logo {
position: absolute;
top: 0;
left: 0;
}
#logo a {
color: #fff;
text-decoration: none;
font-size: 32px;
}
#logo span {
font-size:20px;
color:#48bdee;
margin-left:50px;
}
If you're up to using javascript too, you could do the following.
Set the style of the div to show up as a mouse pointer when hovering over it:
.Logo { cursor:pointer; }
Then using javascript, have a url open with the onclick event:
<div class="Logo" onclick="window.open('google.com')" />
I'm displaying a set of thumbnail images with links on a webpage like this
Here's the HTML
<div id="newsletters-and-journals">
<p id="pubs-caption">Publications</p>
<ul>
<li class="pubs">
<img class="pub-cover" src="images/CXuyv.png" />
<span>Journal - January 2012</span>
</li>
<li class="pubs">
<img class="pub-cover" src="images/vER9H.png" />
<span>Newsletter - May 2012</span>
</li>
</ul>
</div>
and the CSS
#newsletters-and-journals ul { position:relative; top:12px; left:30px; }
.pubs { display:inline; margin-right:60px; }
.pub-cover { width:120px; height:140px; }
also a fiddle http://jsfiddle.net/nK0de/3jeVF/2/
How can I display the links under each corresponding image?
Thank you
It is also works:
.pubs {
display: inline-block;
margin-right: 60px;
width: 120px;
}
width is your image's width.
You can make either <img> or <span> to display:block
http://jsfiddle.net/3jeVF/6/
to solve your problem just add a
br
tag in between
img and span tag.
OK! I just started HTML and CSS today and thought it would be a good approach to learn by building something rather than just reading some text.
[ http://jsfiddle.net/GUkrK/ ]
So I decided to build one sample navigation bar.
<html>
<head>
<title> navigation bar </title>
<link rel="stylesheet" type="text/css" href="menu.css">
</head>
<body>
<ul id="menu">
<li id="menu1">
<a href="http://www.google.com">
<span>GOOGLE</span>
</a>
</li>
<li id="menu2">
<a href="http://www.github.com">
<span>GITHUB</span>
</a>
</li>
<li id="menu3">
<a href="http://www.quora.com">
<span>QUORA</span>
</a>
</li>
<li id="menu4">
<a href="http://www.facebook.com">
<span>FACEBOOK</span>
</a>
</li>
</ul>
<hr/>
</body>
</html>
and the css
ul {
list-style:none;
color:red;
}
#menu {
float:left;
vertical-align:middle;
display:block;
width:600px;
height:108px;
}
#menu li {
display:inline;
font-size:20px;
padding:0px;
}
#menu a:link {
color:white;
font-weight:bold;
padding:20px;
background-color:#27A285;
}
#menu a:hover {
background-color:#E1C618;
color:brown;
}
hr {
height:5px;
background-color:red;
}
But now my problem is the positioning of that horizontal line. Do I have to place that by setting the pixels in absolute or relative positioning? Can't it be done automatically?
And how come the horizontal line does not cover the total width of the browser? and Can I adjust the width of that horizontal line?
EDIT: Thanks everyone. Here is the edited sample http://jsfiddle.net/sunu0000/zdDU5/
Remove float: left; from the CSS definition of #menu.
Sample
http://jsfiddle.net/Y8AAH/3/
CSS for #menu
#menu {
vertical-align:middle;
display:block;
width:600px;
height:108px; /* Looks better with like: 40px !! */
}
Depending on what your layout should look like this definition may be sufficient:
#menu {
display:block;
height:108px; /* Looks better with like: 40px !! */
}
Updated sample: http://jsfiddle.net/Y8AAH/4/
Updated sample with centered menu
#menu {
height:40px;
text-align: center;
}
http://jsfiddle.net/Y8AAH/5/
I sugger you read this before continuing. It appears you don't really know what you're doing, so learn before asking question =p