CSS: header bg image position - html

i'm currenty developing a website, and i have a problem on the header background, so the header that i'm making is:
http://i.imgur.com/h1JLm9A.jpg
and currently i have this:
http://i.imgur.com/LgF6HXm.jpg
I'm trying to put a background image on the header, but to have the correct positioning of the image, it can not be in the header, because the image is also showing out of the header. how can i do this? i try to use z-index but don't works.
html:
<div id="container">
<div id="header">
<div id="logo">
<img src="http://localhost/Yazigi/wp-content/uploads/2013/01/logo.png" width="155" height="85" alt="Yazigi – Araçatuba">
</div>
<span class="site-description ir">Você cidadão do mundo</span>
<form method="get" id="searchform" class="search" action="#">
<input type="text" class="search_input" name="s" id="s" placeholder="Procure aqui">
<input type="submit" class="search_bt ir" name="submit" id="searchsubmit" value="">
</form>
<ul class="menu l_tinynav1">
<li class="current_page_item">Início</li>
<li class="page_item page-item-2">Página de Exemplo</li>
</ul>
</div>
</div>
CSS:
#container {
margin: 0 auto;
max-width: 960px;
padding: 0px 25px;
}
#header {
height: 232px;
background: url(images/topbg.jpg);
margin: 0;
}

Why not use an image in your header instead of using a CSS background?
Put it behind the header with an absolute position and some negative z-index and then just margin it where you want it to be.
Here's some code showing this: (fiddle)
<div id="header">
<img src="http://jamesmcgillis.com/upload/google_logo_1_small(1).jpg"/>
</div>
<style>
#header {
height: 232px;
border: solid;
margin-left: 120px;
}
img {
margin-left: -50px;
z-index:-1;
position:absolute;
}
</style>
Is that what you need?

You have many different approaches here, but probable the most cross-browser compatible would be this:
1. In html: create an outer div, (of course, with 100% width) and add to it the map/drawing image background.
<div id="outer-container">
<div id="container">
<div id="header">... etc
</div>
</div>
</div> <!-- outer-container-->
2. In css:
a) Add the gradient image to the body with background property.
b) Add the map / drawing image to the outer-container with background property.
body {
background: (your-gradient-gray-image.jpg) repeat-x;
}
#outer-container {
background: url(images/topbg.jpg) no-repeat center top;
}

Related

HTML does not overtake background image

I want to change the background of a Website from a normal color to a picture.
The CSS-Code:
.bg {
opacity: 5;
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 100%;
background-image: url('../../assets/pics/bg.jpg');
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: 5;
}
If I write
<body class="bg">
in the HTML File, the Website is white. (If I add blur Effects, they will shown over all other elements). If I do
<img id="logo" src="path to img">
It works but I want it with CSS because its smarter :D
The image is here: (from the CSS-File)
../../assets/pics/bg.jpg
And I dont get any Errors in Chrome (in Developer tools)
Can u help me?
(If it helps, i want to edit the page "mcggehrden.de/idesk/v3" and want to set a a custom background)
You need something like this?: View Full Size
<div class="container">
<div class="row text-center">
<div class="col-md-3 col-md-offset-5">
<h1>MCG Gehrden</h1>
<form class="login-form" action="/idesk/v3/login_check" method="post">
<h3><span class="glyphicon glyphicon-user"></span> IServ-Anmeldung</h3>
<input class="form-control" type="text" name="_username" value="" placeholder="Account" required="required" autofocus="autofocus"/>
<input class="form-control" type="password" name="_password" placeholder="Passwort" required="required" />
<div class="checkbox">
<label><input type="checkbox" id="remember_me" name="_remember_me" /> Angemeldet bleiben</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Anmelden</button>
</form>
</div>
</div>
CSS:
*{ padding: 0; margin: 0; }
body {
color: white;
background:
url(https://mcggehrden.de/idesk/v3/img/logo.png) 100% 60vh no-repeat,
url(https://mcggehrden.de/idesk/v3/img/circles.png) 0px 100px no-repeat,
#244c7f ;
}
form{
background-color: white;
padding: 20px;
}
When adding an img to body in css you don't have necessary to specify a class for the "body" tag. In css you can directly say body {..your styles..}. Then, insted of top, left, right and bottom say directly margin:0. Also the position absolute should not be there and an opacity of 5 cannot exist. A z-index of 5 would not do anything. My suggestion is to put a width of 100% and a height of auto or the height be specified in "px". Try this and let me know.

Adding a link to images in the footer

My footer contains three images and i want to add a link to (coyright and companysite) that once you click on the image, it takes you to the website i tried different methods i found here but its not working with me. what should i add?
The page code:
<body>
<div id="wrap">
<div id="header">
</div>
<div id="main">
<div id="content">
</div>
</div>
</div>
<div id="footer">
<div id="img-1">
</div>
</div>
</body>
the CSS:
* {margin:0;padding:0;}
html, body {
height: 100%;
background: url('../../fresh/img/bg.png') repeat;
}
#wrap {
min-height: 100%;
}
#header {
background: url('../../fresh/img/header.png') no-repeat top center;
display:block;
text-indent:-9000px;
width: 100%;
height: 237px;
}
#main {
overflow:auto;
padding-bottom: 200px;}
#content {
background: url('../../fresh/img/log-in.png') no-repeat top center;
display:block;
width: 100%;
height: 201px;
}
#footer {
position: relative;
margin-top: -200px; height: 200px;
clear:both;
}
body:before {
content:"";
height:100%;
float:left;
width:0;
margin-top:-32767px;
}
#img-1 {
bottom:0;
height:200px;
background : url('../img/footer.png') center no-repeat,
url('../img/companysite.png') left no-repeat,
url('../img/copyright.png') right no-repeat, ;
}
There are two ways to link a website.(If you use html)
1.By using Anchor tag (Most prefered method)
Your element tags like p,span,img,...
2.By using window.location function
<div onclick="window.location='http://www.yahoo.com'" style="cursor:pointer"></div>
Check fiddle
Just wrap your img tag in a link tag like so:
<img src="my_img.jpg>
Then any part of the image will be a clickable link.
<div id="img-1" onclick="window.location='http://www.google.com'" style="cursor:pointer">
</div>
You have to add images inside anchor elements as shown:
<div id="footer">
<div id="img-1">
<img src="yourImage1"/>
<img src="yourImage2"/>
<img src="yourImage3"/>
</div>
</div>
That's it.
It looks like you are placing all images as backgrounds in a div. Use three separate images instead:
<div id="footer">
<div id="img-1">
<img src="../img/footer.png" alt="" />
<img src="../img/companysite.png" alt="" />
<img src="../img/copyright.png" alt="" />
</div>
</div>
And remove the backgrounds from the CSS:
#img-1 {
bottom:0;
height:200px;
}
Change the
<div id="img-1">
</div>
into
<a href="your desired link">
<div id="img-1">
</div>
</a>
First of all you need to clarify that on one HTML page you cannot use more than one same name ID tag or else you will get W3C validation error on your page.
In order to achieved what you are looking for is as under:
//This is your HTML code
<div id="footer">
<div id="img-1">
CopyRights
</div>
<div id="img-2">
Company
</div>
</div>
**//Here is your CSS Code**
#footer {
position: relative;
margin-top: -200px; height: 200px;
clear:both;
bottom:0;
height:200px;
background : url('../img/footer.png') center no-repeat
}
#img-1 {
url('../img/companysite.png') left no-repeat;
}
#img-2 {
url('../img/copyright.png') right no-repeat, ;
}

Making my header & wrapper fluid/responsive with % doesnt seem to work

So i wanted to make my website fluid. So i started with my wrapper and header. The css:
#wrapper {
max-width:1600px;
width:100%;
margin:0 auto;
}
#header {
margin: 0 auto;
width: 100%;
height: 7.5%;
background-color: #0066FF;
display: table-cell;
vertical-align: middle;
}
The HTML:
<div id="wrapper">
<div id="header">
<div id="logo_wrapper">
<span class="logonaam1">O</span><span class="logonaam2">b</span><span class="logonaam1">l</span><span class="logonaam2">e</span><span class="logonaam1">c</span><span class="logonaam2">t</span><span class="logonaam1">a</span><span class="logonaam2">r</span><span class="logonaam1">e</span>
</div>
<form action="login.php" method="post">
<div id="aanmeldform_submit">
<input type="submit" name = "submit_login" value="Aanmelden" id="submit_knop" />
</div>
<div id="aanmeldform_wachtwoord">
<input type="password" name ="password" value="" id="aanmeld_knop" required placeholder="Voer je wachtwoord in" />
</div>
<div id="aanmeldform_email">
<input type="email" name="email" value="" id="aanmeld_knop" required placeholder="Voer je e-mail in" autofocus/>
</div>
</form>
</div>
The header should span the entire width of the screen, just like the wrapper. But for some reason, when i set the width of the header also to 100% the header only is like 1/3 of the screen. When i change the width of my header to around 1 - 10 % it DOES span the whole width for some reason. Anyone know what is causing this? Also included a fiddle for better understanding: http://jsfiddle.net/4J7JJ/
When you set the header in the fiddle to 1% you can see it does span the entire width for some reason..
Thanks in advance!
Try change display
#header {
margin: 0 auto;
width: 100%;
height: 7.5%;
background-color: #0066FF;
display: inline-table; /* that fix the problem */
vertical-align: middle;
}

My divs are out of order and aligned at the bottom of the page?

Here's the code in the body of my HTML:
<div id="mtx_bckgd">
<p id="mtx_txt"></p>
</div>
<div class="outerdiv" id="headerbox">
<div id="uwlogo">
<img src="uwlogo.png" height="50px">
</div>
<div id="JaminWEB">
<h1>JaminWEB</h1>
</div>
</div>
<div class="outerdiv" id="navbar">
<input type="button" class="navbutton" value="Running Calculator"/>
<input type="button" class="navbutton"/>
<input type="button" class="navbutton"/>
</div>
<div class="outerdiv" id="footer">
<p>Last modified: March 21st, 2014</p>
</div>
Here's the relevant CSS:
#mtx_bckgd
{
font-family: "Courier New";
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
z-index: -1;
background: linear-gradient(180deg, #39275b, #FFF);
}
#headerbox
{
width: 80%;
height: 50px;
}
#navbar
{
width: 80%;
height: 30px;
}
#footer
{
position: absolute;
bottom: 0px;
height: 100px;
width: 80%;
}
The headerbox and navbar are supposed to be aligned at the top in their respective orders. The footer is supposed to be aligned at the bottom. What's going on that is making my footer ABOVE the other two, and everything aligned at the bottom?
Remove the:
height: 100%;
from the #mtx_bckgd element
Also, nothing to do with the problem, but change
<img src="uwlogo.png" height="50px">
to
<img src="uwlogo.png" height="50px" />
As your image tag isn't closed
The mtx_bckgd is occupying 100% width and 100% height (so all your screen). The footer is absolute at the bottom, so it's over the mtx_bckgd and at the bottom of your screen. Finally, the two other div tags, are at the bottom cuz again the mtx_bckgd is occupying all the screen and they have to be after it.
What layout do you want to achieve ?

Layout on my page changes when maximizing the page, how is this stopped?

I want all my information to be in the center as you can see in the link below:
http://jsfiddle.net/EdHEu/
It looks fine BUT when i stretch/maximize the browser page the layout changes by text going right and then the boxes moving.
How is this stopped?
Thanks!
James
NOTE: Your Link is not working.
If your setup is like this:
<body>
<div id="main">
<div id="content">
<!--Content-->
</div>
<div id="sidebar">
<!--Sidebar-->
</div>
</div>
</body>
To Center the content ( to give the page a fixed width ), you need to use this CSS:
#main {
width:960px /* Give it a width */
margin: 0 auto; /* It will Center the #main */
}
This way, you can give the page a fixed width and make the layout fixed.
Why don't you take a look at this code (jsfiddle) & see if that cleans it up a bit more, too.
HTML:
<div class="content">
<form class="location" action="weezyresults.php" method="post">
<div>
<label for="job">job?</label>
<div class="input" name="job" >
<!-- change me back to your inputs,
and in the css change '.input' to 'input' -->
</div>
<label>job title or keywords</label>
</div>
<div>
<label for="where">where?</label>
<div class="input" name="where" >
<!-- change me back to your inputs,
and in the css change '.input' to 'input' -->
</div>
<label>town, city or county</label>
</div>
</form>
</div><!-- end .content -->
CSS:
.content {
margin:0 auto;
width:200px;
}
form>div { margin-bottom: 10px; }
form .input {
background: #ffffff;
border: 1px solid;
color: #BDBDBD;
height:35px;
margin:2px;
width: 320px;
}
div>label:first-child {
color: #585858;
font: bold 16px helvetica;
height:20px;
margin: 4px;
width: 320px;
}
div>label:last-child {
color: #585858;
font:italic 13px HelveticaNeue-Light;
margin: 4px;
}
.center {
text-align:center;
margin:0 auto;
width: 651px;
}