w images in header float issue - html

I have a header that is larger than most screen widths. I centered that and I have the overflow hidden so when you expand your browser on a bigger screen more of it is visible. I also have 2 images on top of that, one floating right and one floating left. my problem is that the left image is in place floating left but the right image won't go all the way right. both if I put both images on the same z-index they just stack instead of floating right and left. Any suggestions? here is my css and html:
#triangleleft{
width:100%;
height:531px;
z-index:58;
position:absolute;
top:+53px;
}
#triangleright{
width:100%;
height:531px;
z-index:59;
position:absolute;
top:+53px;
}
.triangleleft{
background:url(Layer-58.png)no-repeat;
float:left;
margin-left:0px;
height:531px;
width:100%;
}
.triangleright{
background:url(Layer-59.png)no-repeat;
float:right;
margin-right:0px;
height:531px;
width:100%;
}
<div id="triangleleft">
<div class="triangleleft"></div>
</div>
<div id="triangleright">
<div class="triangleright"></div>
</div>
also here is the code for my header image that I think is screwing this up
#wrapper {
height:100%;
position: relative;
}
#Layer-57 {
position: relative;
height:529px;
background:#3b96a9 url(layer-57.jpg) top center no-repeat;
top:-529px;
overflow-x: hidden;
z-index: 57;
}
<div id="wrapper"> <div id="Layer-57"></div> </div>

replace your style with this
<style>
#triangleleft {
width:90%;
height: 531px;
z-index: 58;
position: absolute;
top: +53px;
}
#triangleright {
width:90%;
height: 531px;
z-index: 59;
position: absolute;
top: +53px;
}
.triangleleft {
background: url(Layer-58.png)no-repeat;
float: left;
margin-left: 0px;
height: 531px;
width: 100%;
}
.triangleright {
background: url(Layer-59.png)no-repeat;
float: right;
margin-right: 0px;
height: 531px;
width: 100%;
}
</style>

Revised Answer (previous answer removed for clarity's sake):
Looking closer at the leaderbe.com page you referenced in your comment below, I noticed that the HTML structure of the divs was quite different than what you had. You need to put the triangleright div inside the triangleleft div and use styles like follows:
See this jsfiddle: http://jsfiddle.net/uKrNT/2/
<div id="wrapper"> <div id="Layer-57">layer 57</div> </div>
<div id="triangleleft">
<div id="triangleright">
</div>
</div>
#triangleleft{
width:100%;
height:531px;
z-index:58;
position:absolute;
top:+53px;
float:left;
background:red url(http://www.leaderbe.com/images/diamond-left.png)no-repeat;
margin-left:0px;
overflow:visible;
opacity:.5;
}
#triangleright{
width:100%;
height:531px;
z-index:59;
float:right;
background:blue url(http://www.leaderbe.com/images/diamond-right.png)no-repeat;
margin-right:0px;
opacity: .5;
overflow:visible;
}
#wrapper { height:100%; position: relative; }
#Layer-57 { position: relative; height:529px; background:#3b96a9 url(layer-57.jpg) top center no-repeat; top:-529px; overflow-x: hidden; z-index: 57; }

Related

CSS - Dynamic Div minimum / maximum position

I have a div containing the website logo, that I stuck in the top left corner of my website.
In order to have it dynamic, I put its position on a 10% screenwidth from the left. Now the problem occurs when the browser gets smaller than the width of my content, it obscures important buttons or text on the website.
I cant seem to figure out how to resolve this and any input would be great.
Edit: added additional divs to contain both the Logo banner and the Login-menu above the website;
Header.php:
<div id="navcontainer" class="navcontainer-div">
<div id="bannier" class="bannier-div">
<img src='/img/banner.png'>
</div>
<div id="navigation" class="navigation-div">
<table width='100%'>menu content</table>
</div>
</div>
Style.css:
.navcontainer-div
{
margin-left:-10px;
max-width: 100%;
width:100%;
/*height: 125px;
background-color: #AEB861;*/
background-image: url('/img/header_bg.png');
background-repeat: repeat-x;
display:block;
border-radius: 3px;
top:0;
position: fixed;
}
.navigation-div
{
z-index: 2;
max-width:1000px;
height:60px;
background-color: #E4EEB9;
margin: 0 auto;
color: #000;
border-radius: 3px;
}
.bannier-div
{
z-index: 3;
left:10%;
position: fixed;
width:100%;
max-width:150px;
}
I think you should user another class or id with parent element.
Example:
At page http://webstore.thelifeforge.nl/about.php we have id navigation
At page http://webstore.thelifeforge.nl don't have id navigation
So we can write:
.bannier-div
{
z-index: 3;
left:10%;
position: fixed;
width:100%;
max-width:150px;
}
#navigation .bannier-div
{
z-index: 3;
left:5%;
position: fixed;
width:100%;
max-width:100px;
}

A simple div layout using position

Let's see if I can explain this correctly. I want a header, always visible AND content AND a footer that is hidden behind the content, that becomes visible when scrolled to the footer. Here's what I have so far...
#container {
height:100%;
width:100%;
position:relative;
}
#top {
height:25vh;
width:100%;
background-color:red;
position:fixed;
top:0;
}
#content {
height:120vh;
width:100%;
background-color:green;
position:relative;
}
#bottom {
height:35vh;
width:100%;
background-color:blue;
position:fixed;
bottom:0;
}
<div id="container">
<div id="top">
</div>
<div id="content">
</div>
<div id="bottom">
</div>
</div>
What this code currently does: Header is hidden behind content and footer is always visible overlapping content.
Here is the current test page... http://next-factor.com/test-layout.php
Much help is greatly appreciated. Thank You!
give a z-index in #top
#top {
background-color: red;
height: 25vh;
position: fixed;
top: 0;
width: 100%;
z-index: 999;
}
it will make header visible.
and remove position:fixed from #bottom
#bottom {
background-color: blue;
bottom: 0;
height: 35vh;
width: 100%;
}
hope this will solve your problem
here is the working example http://jsfiddle.net/a3ru9d4d/
in this example I have added padding top in the container so that content inside the container will not hide behind the header.
I think you want something like this:-
*{margin:0;padding:0}
#container {
height:100%;
width:100%;
position:relative;
}
#top {
height:25vh;
width:100%;
background-color:red;
position:fixed;
top:0;
z-index: 1;
}
#content {
height:120vh;
width:100%;
background-color:green;
position:relative;
}
#bottom {
height:35vh;
width:100%;
position:relative;
z-index:-2;
background-color:#31353a;
}
<div id="top">
</div>
<div id="content">
</div>
<div id="bottom">
Footer
</div>
</div>
I hope it will helps you.
Take a look at this. I've introduced two new CSS definitions that achieve what I think you want.
https://jsfiddle.net/b8my8h5j/
I added z-index definitions. The higher the index, the higher it is in a non-static positioning stack. the content header has 30, so it appears above 20 for the content, but the footer has 10, so t's always at the back.
I added a margin-bottom to the content so that there's space for you to scroll down and have the footer be completely visible.
Update:
https://jsfiddle.net/b8my8h5j/1/
Also cleared padding/margin on the body and html tags so that the blocks fit together snugly.
Added a margin-top to the content so that the top of the green box is visible.
I think this produces what you want: z-indexes on all three, and making room at the bottom of content for the footer to show completely when you scroll to the end of the page
#container {
height:100%;
width:100%;
position:relative;
}
#top {
height: 25vh;
width: 100%;
background-color: red;
position: fixed;
top: 0;
z-index: 3;
}
#content {
height: 120vh;
width: 100%;
background-color: green;
position: relative;
margin-bottom: 33vh;
z-index: 2;
}
#bottom {
height: 35vh;
width: 100%;
background-color: blue;
position: fixed;
bottom: 0;
z-index: 1;
}
<div id="container">
<div id="top">
</div>
<div id="content">
</div>
<div id="bottom">
</div>
</div>

How do i make my picture and paragraph in the middle of my page screen

My problem is the picture and the paragraph is not in the center of the page screen it goes to the bottom instead. Can anyone help me with this?
current output: http://jsfiddle.net/YMCLJ/1/
<p class="center">Must be center in the screen</p>
<img class="center" src="http://i38.photobucket.com/albums/e149/eloginko/hello_zpsc60ffbf3.gif"/>
css
.center {
position: absolute;
left:50%;
top:50%;
}
You need to set a negative top and left margin to 1/2 the image height/width.
.center {
position: absolute;
left:50%;
top:50%;
margin-top:-150px;
margin-left:-150px;
}
Updated JSFiddle
You're looking for the absolute centering technique.
There are many ways to do it, and they all have their advantages and disadvantages, but this is the easiest:
.center{
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
text-align: center;
}
Demo
Try This code:
img.center {
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
margin:auto;
}
p.center{
text-align:center;
margin-top:50px; // change it according to your need
}
Live Demo: http://jsfiddle.net/UTn2N/
If you will put both image and paragraph inside a div then it will be easy to place them in center.
This should centre the element for you regardless of its size:
.center {
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
margin:auto;
}
http://jsfiddle.net/XGq5V/
UPDATE:
It gets rather more complicated to centre an element that has no explicit dimensions. In your case, you should wrap the elements you wish to centre in a parent <div>:
<div class="center">
<img src="http://i38.photobucket.com/albums/e149/eloginko/hello_zpsc60ffbf3.gif" />
</div>
<div class="center">
<p>Must be center in the screen</p>
</div>
...so we can centre the children within using a 'ghost' element to hold it open:
.center {
text-align: center;
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
}
.center:before {
content:'oooh, a ghost';
display: inline-block;
height: 100%;
vertical-align: middle;
width:1px; overflow:hidden;
text-indent:-1000px;
margin-right: -1px;
}
/* center the child */
.center > * {
display: inline-block;
vertical-align: middle;
}
http://jsfiddle.net/XGq5V/1/
Some more discussion on the various techniques can be read at http://css-tricks.com/centering-in-the-unknown/
If you want to have elements in absolute middle, try this simpler method:
HTML:
<div class="centered-container">
<div class="centered-elements">
<p>Must be center in the screen</p>
<img src="http://i38.photobucket.com/albums/e149/eloginko/hello_zpsc60ffbf3.gif"/>
</div>
</div>
CSS:
centered-container {
display: table;
position: absolute;
table-layout: fixed;
width: 100%;
height: 100%;
}
.centered-elements{
display: table-cell;
vertical-align: middle;
text-align: center;
}
http://jsfiddle.net/YMCLJ/13/

fixed css header with special width

hello stackoverflow community,
i have a problem with my fixed header. my html structur looks like that:
<div id="site_wrapper">
<div id="site_header">Header</div>
</div>
The CSS Looks like this:
div#site_wrapper {
max-width:1500px; min-width:900px;
}
div#site_header {
position:fixed; left:50%; top:0px; z-index:10;
height:160px; width:1500px;
margin-left:-750px;
background-color:#fff;
}
My Problem is, that i need the header centered and fixed with the width 1500 ...
Some Ideas?
Since #site_header is inside site_wrapper you need to center #site_wrapper div, i also update the #site_wrapper code to be always centered inside #site_wrapper
div#site_wrapper {
margin-right: auto;
margin-left:auto;
max-width:1500px; min-width:900px;
}
div#site_header {
position: fixed;
top:0px;
z-index:10;
height:160px; width:1500px;
margin-left:auto;
margin-right:auto;
background-color:#fff;
}
If you want to make the header fixed, center align and some special width, try updating you CSS code with below:
div#site_wrapper {
max-width:1500px;
min-width:900px;
margin: 0 auto;
}
div#site_header {
position:fixed;
z-index:10;
height:160px;
width:1500px;
background-color:#ffff00;
}
Refer this fiddle: http://jsfiddle.net/aasthatuteja/B2Tnj/
Hope this helps!
To have a fixed header just use the following code:
div#site_header {
position: fixed;
top: 0px;
left: 0px;
z-index: 10;
height: 160px;
width: 100%;
margin: 0;
text-align: center;
padding: 0;
}

7 Divs, how to make they stay where the picture say?

alt text http://img13.imageshack.us/img13/9776/dviswheretogo.png
Blue is where the image of the corners will go
Green is a repeating image on the x axis on the top, all part of the same template!
And orange is a simgle image repeating on the y axis
For clarification here is what I've tried so far, i'm angry about this because when I use relative position it breaks because of an with background that is above! Anyway I need to define a height and width for each item!
.sheet {position:relative;
top:140px;
width:1000px;}
.tl {
background:url(../images/sheet_top_left-trans.png) no-repeat;
width:20px;
height:20px;
top:0px;
left:0px;}
.tm {
background:url(../images/sheet_top-trans.png) repeat-x;
width:960px;
height:20px;}
.tr {
background:url(../images/sheet_top_right-trans.png) no-repeat;
width:20px;
height:20px;
top:0px;
right:0px;}
.content {
background:url(../images/sheet_middle.png) repeat-y;
top:20px;
width:1000px;
height:400px;}/* Demonstration only, please remove later */
.bl {
background:url(../images/sheet_bottom_left-trans.png) no-repeat;
width:20px;
height:30px;}
.bm {
background:url(../images/sheet_bottom-trans.png) repeat-x;
height:30px;
width:960px;
bottom:0px;
left:20px;}
.br {}
and the html
<div class="sheet"><!-- Glass Effect Starts here -->
<div class="tl"></div>
<div class="tm"></div>
<div class="tr"></div>
<div class="content">Here we go again</div>
<div class="bl"></div>
<div class="bm"></div>
<div class="br"></div>
If I use absolute postitioning I can't make the bottom images stick to it! tho it works at the top!
Now I've found I way to do it that is cross-browser (even IE6 just don't use transparent PNG as I did) here we go:
HTML:
<div class="sheet">
<div class="top_sheet">
<div class="tl"></div>
<div class="tm"></div>
<div class="tr"></div>
</div>
<div class="middle">.</div>
<div class="bottom_sheet">
<div class="bl"></div>
<div class="bm"></div>
<div class="br"></div>
</div>
</div><!-- End of the sheet class -->
CSS:
.sheet {position:relative;
width:1000px;
top:10px;}
.top_sheet {width:1000px;
height:20px;}
.tl {float:left;
background:url(../images/sheet_top_left-trans.png) no-repeat;
height:20px;
width:20px;}
.tm {float:left;
background:url(../images/sheet_top-trans.png) repeat-x;
height:20px;
width:960px;}
.tr {float:right;
background:url(../images/sheet_top_right-trans.png) no-repeat;
height:20px;
width:20px;}
.middle {position:relative;
background: url(../images/sheet_middle.png) repeat-y;
width:1000px;
height:400px;}
bottom_sheet {width:1000px;
height:30px;}
.bl {float:left;
background:url(../images/sheet_bottom_left-trans.png) no-repeat;
width:20px;
height:30px;}
.bm {float:left;
background:url(../images/sheet_bottom-trans.png) repeat-x;
width:960px;
height:30px;}
.br {float:right;
background:url(../images/sheet_bottom_right-trans.png) no-repeat;
width:20px;
height:30px;}
Trying to use the same html you already have, here is something that seems to work pretty well.
Move the corners into an all encompassing top and bottom bar. And then float the respective corners left and right.
CSS:
.sheet {
position:relative;
width:1000px;
top:140px;}
.tl {
background:url(images/sheet_top_left-trans.png) no-repeat;
float:left;
width:20px;
height:20px;
margin-left:-20px;}
.tm {
background:url(images/sheet_top-trans.png) repeat-x;
height:20px;
margin-left:20px;}
.tr {
background:url(images/sheet_top_right-trans.png) no-repeat;
float:right;
width:20px;
height:20px;}
.content {
background:url(images/sheet_content.png) repeat-y;
clear:both;
height:200px;}/* Demonstration only, please remove later */
.bl {
background:url(images/sheet_bottom_left-trans.png) no-repeat;
float:left;
width:20px;
height:30px;}
.bm {
background:url(images/sheet_bottom-trans.png) repeat-x;
height:30px;}
.br {
background:url(images/sheet_bottom_right-trans.png) no-repeat;
float:right;
width:20px;
height:30px;}
HTML:
<div class="sheet"><!-- Glass Effect Starts here -->
<div class="tm">
<div class="tl"></div>
<div class="tr"></div>
</div>
<div class="content">Here we go again</div>
<div class="bm">
<div class="bl"></div>
<div class="br"></div>
</div>
</div>
Have you tried some cross-browser css framework, e.g. http://www.blueprintcss.org?
These frameworks usually let you define grids and will help you to overcome browser-specific quirks by resetting certain css properties ...
Fluid width containers with rounded corners using valid CSS and XHTML
The method I usually see is nesting all the divs to layer them, then setting the background-repeat and background-position on each one. Basic example:
<div class="tl">
<div class="tr">
<div class="content">Here we go again</div>
</div>
</div>
With CSS:
.tl, .tr {
width: 100%;
height: 100%;
}
.tl {
background: url("tl.png") no-repeat 0 0;
}
.tr {
background: url("tr.png") no-repeat 100% 0;
}
Simply scale that up to use all your separate images. You'll need to have the sides first (on the outside of the 'div nest') and the corners last (on the inside, right before the content div).
It's a classic case of "divitis", but it's hard to avoid until CSS3 is well supported (where you can use multiple backgrounds or simply a border image). You might was to check out Sliding Doors, which shows a technique for reducing the number of elements/images needed.
css:
.sheet {
position:relative;
top:140px;
width:1000px;
}
.tl {
background:url(blue.bmp) no-repeat;
width:20px;
height:20px;
top:0px;
left:0px;
}
.tm {
position: absolute;
background:url(green.bmp) repeat-x;
width:960px;
height:20px;
left: 20px;
top: 0px;
}
.tr {
position: absolute;
background:url(blue.bmp) no-repeat;
width:20px;
height:20px;
top:0px;
right:0px;
}
.content {
background:url(orange.bmp) repeat-y;
top:20px;
width:1000px;
height:400px;}/* Demonstration only, please remove later */
.bl {
background:url(blue.bmp) no-repeat;
width:20px;
height:30px;}
.bm {
position: absolute;
background:url(green.bmp) repeat-x;
height:30px;
width:960px;
bottom:0px;
left:20px;}
.br {
position: absolute;
background:url(blue.bmp) no-repeat;
width:20px;
height:30px;
top:420px;
right:0px;
}
html:
<div class="sheet"><!-- Glass Effect Starts here -->
<div class="tl"></div>
<div class="tm"></div>
<div class="tr"></div>
<div class="content">Here we go again</div>
<div class="bl"></div>
<div class="bm"></div>
<div class="br"></div>
I put absolute positioning on each divs so that we can position it side by side. Hope it helps.
BTW, I changed the background url. :)
Winks as he says this and may regret it:
You know, if you used a table... ;>P!
(Now, waits for the tables vs. css crowd to unleash!)
This looks like your regular, garden-variety rounded corners 'section'.
Here's one without images:
http://www.html.it/articoli/nifty/index.html
Here's one with:
http://kalsey.com/2003/07/rounded_corners_in_css/
When you're finished coding it and it looks like what you want, turn it into a code snippet and keep it.
I don't mean to be a smartarse, but you hardly need 7 divs for what you try to achieve. Five divs are enough (in most case you don't even need that. I really don't know how to explain, but you can check http://www.nil.com/english (Quick links or Get support boxes) for source.
Also, there is a great book about it called "Bulletproof web design"
You were close. You yet have to position the containing element relative (so that all absolute positioned child elements are relative to it) and to position the corner parts absolute. Here's a SSCCE:
<!doctype html>
<html lang="en">
<head>
<title>SO question 1898479</title>
<style>
.sheet {
position: relative;
width: 200px;
}
.tl {
position: absolute;
width:20px;
height:20px;
top: 0;
left: 0;
background: blue;
}
.tm {
position: absolute;
height:20px;
top: 0;
left: 20px;
right: 20px;
background: green;
}
.tr {
position: absolute;
width: 20px;
height: 20px;
top: 0;
right: 0;
background: blue;
}
.content {
background: orange;
padding: 20px 0; /* Padding must be at least as much as the "borders" are thick. */
height: 300px;
}
.bl {
position: absolute;
width: 20px;
height: 20px;
bottom: 0;
left: 0;
background: blue;
}
.bm {
position: absolute;
height: 20px;
bottom: 0;
left: 20px;
right: 20px;
background: green;
}
.br {
position: absolute;
width: 20px;
height: 20px;
bottom: 0;
right: 0;
background: blue;
}
</style>
</head>
<body>
<div class="sheet">
<div class="tl"></div>
<div class="tm"></div>
<div class="tr"></div>
<div class="content">Here we go again</div>
<div class="bl"></div>
<div class="bm"></div>
<div class="br"></div>
</div>
</body>
</html>
You only need to ensure that you're using the strict doctype as used in the above example so that it works in IE as well.