Basically my goal is for my page content div to be encapsulated in a round rectangle. Sort of like this:
Top of round rect (White)
Page content (uses a white rectangular css background)
Bottom of round rect(White)
So then the page content section can be as long as I need and retain the round rect shape. I'm just not sure the best way to do this. I tried adding an img to the top of pagecontent div, but the transparent areas were overridden by the pagecontent's background. Thanks
If I understand what you mean you should put the top and bottom divs outside of the content div :
<html>
<div id=top> </div>
<div id=middle>
... insert page content ...
</div>
<div id=bottom> </div>
</html>
and then in the css
#top {
background : url("top.png") no-repeat bottom center;
height : <height of image in pixels>px;
padding : 0;
margin: 10px auto 0 auto;
width:<required width>
}
#middle {
background : url("middle.png") repeat-y top center;
padding : 0;
margin: 0 auto 0 auto;
width:<required width>
}
#bottom {
background : url("bottom.png") no-repeat top center;
height : <height of image in pixels>px;
padding : 0;
margin: 0 auto 10px auto;
width:<required width>
}
The famous Sliding Doors technique may be what you need. You may need to add an additional repeating image to make it infinitely long.
Related
I have some HTML/CSS that I came up with, I have centered the page and attempted to get an image either side (or behind it) of the centered page but I'm not sure how.
Sorry for the bad explanation, here is my code:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("/images/background.png")
}
#wrap {
width: 700px;
margin: 0 auto;
}
hr.one {
margin-top: 5px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<title>ItzJavaCraft | Home</title>
<div id="wrap">
<h1 align="center">ItzJavaCraft</h1>
<hr class="one">
<p>More coming soon...</p>
</div>
</body>
</html>
I want to be able to get the background.png to the left, and the right of the page.
P.S: Sorry of I have done anything incorrect here, I am new.
Any help would be great!
Thanks,
—ItzJavaCraft
Here is a way to get one image the fullwidth and height of the screen in the background.
body {
background: url("http://placehold.it/400x300/ff66cc/ffffff&text=icon1") no-repeat center center fixed;
background-size: cover;
}
#wrap {
width: 700px;
margin: 0 auto;
}
hr.one {
margin-top: 5px;
margin-bottom: 5px;
}
<title>ItzJavaCraft | Home</title>
<div id="wrap">
<h1 align="center">ItzJavaCraft</h1>
<hr class="one">
<p>More coming soon...</p>
</div>
There's one simple error causing the background to not display: the relative URL should not start with "/" (unless, of course, you want to use an absolute path and are using a system where / refers to your root directory). Additionally, you'll need to use the background-size or background-repeat property to make the image fill up the entire page.
If you want your "wrap" element to remain white, you can just add a background-color to that element (adjusting the size of the element as necessary to get the coverage you're looking for).
The background-image property sets one or more background images for an element. The background of an element is the total size of the element, including padding and border (but not the margin). By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.
Tip: Always set a background-color to be used if the image is
unavailable..If you want to provide a position in a background image,
you can use some properties like:
Property:
background-position
Also, you can use a shorthand for that like jack blank code, but if this is hard to use for you, you can make it for separate like:
Full background image to your page:
background-position: cover;
Or if you want to change the position, you can use center, left, right, and top
For example:
background-position: center top;
or
background-position: left center;
or
background-position: top center;
etc.
You can learn about this property with more examples here:
http://www.w3schools.com/cssref/pr_background-image.asp
I'm at my wits end with this one.
I have a couple of divs. They all have a downward pointing arrow. It should be centered in the middle, on the brown line and on top of everything. The last div should also have the arrow. I tried z-index, absolute & relative positioning and nothing works.
If you click the title, the box opens. The arrow should stay on the line in the exact spot. This really doesn't seem all that difficult to me, but somehow I can't make it work.
Here is a fiddle:
http://jsfiddle.net/8eLwr
<article id="made" data-magellan-destination="made">
<div class="blocks-holder wide made">
<div class="block wide" id="">
<div class="openblock">
<div class="maak-competences">
<h2>title</h2>
<h4>tagline</h4>
<div class="arrow-down"></div>
</div>
Thanks so much in advance!
Remove the absolute positioning from the arrow and instead set it to display as block and give it margin: 0 auto to centralise it:
.arrow-down {
...
background-position: bottom;
display: block;
margin: 0 auto -36px auto;
}
Note that I've also set its background-position to bottom to make the background image sit directly at the bottom of the element.
JSFiddle demo.
Edit: from comments:
Yes, it should be just underneath the brown line, so it sort of looks like this: -----v------- The two point of the V should touch the line
This is a bit of a large change. We need to remove the background from the individual blocks (to stop them overlapping the arrow), then remove the float from the block container (to fix the height), then finally give the container the white background and increase the negative margin on the arrow:
.blocks-holder .block {
...
float: left; /* Remove this. */
}
.blocks-holder .block.wide {
...
background: transparent;
}
.blocks-holder.wide {
...
background: #fff;
}
.arrow-down {
...
margin: 0 auto -46px auto;
}
JSFiddle demo.
I have a centered image in the background, but I need my main background-color to stretch as much as the image and stay at the center.
Here is the css for body background
body{padding:0; margin:0; background:url(/b.jpg) center 10px no-repeat;}
Here is the css for main background
.main{background:#4e4645;}
Ive tried background-position and margin percents with no luck.
You can use margin: 0 auto to center your .main div within the body. Then all you need to do is set the width of .main to be equal to the width of your body's background image.
.main {
margin: 0 auto;
width: 300px;
background: #4e4645;
}
See DEMO.
Is this what you're trying to achieve?
http://jsfiddle.net/aX24s/1/
In the example I'm using two background colours, obviously substitute an image in. I've put 50% opacity on the inner div to show that they're both exactly matched in size (one block is bright green, one is red, so the colours mix).
You have the two backgrounds the same size and overlaid exactly.
HTML:
<body>
<div class="outer_div">
<div class="inner_div">
</div>
</div>
</body>
CSS:
.outer_div {
width:50px;
margin:0 auto;
height:50px;
background-color:#dd0000;
}
.inner_div {
background:#00dd00;
width:100%;
opacity:0.5;
height:100%;
}
I want to recreate the following header:
The problem is that the content is centered in the white section. Grey is the background of body and the header is 100% of screen.
What I have now is:
CSS
.top_left {
background:#3c4d74;
}
.top_right {
background:#2f3a5a;
}
.top_center {
background:#3c4d74 url(http://img85.imageshack.us/img85/2816/headerbgo.jpg) no-repeat right top;
height:140px;
}
#page,
.top_center {
max-width:1000px;
margin:0 auto;
}
#page {
background:#FFF;
}
body {
background:#DEDEDE;
}
HTML
<body>
<div id="top-header">
<div class="top_left"></div>
<div class="top_center">
LOGO
</div>
<div class="top_right"></div>
</div>
<div id="page" class="hfeed">
MY content bla bla bla
</div>
</body>
Which you can see working on http://jsfiddle.net/gTnxX/ (I put max width 600px instead of 1000px so you can see it on fiddle).
How can I make the left side soft blue and right side hard blue at any resolution?
To do this you need to be very aware of how positioning works.
The #header-bg is positioned so it falls below #wrapper. It is 100% width, 140px high with 2 divs which both take up 50% of that space and they both get a different colour for left/right.
The #wrapper is relatively positioned to make z-index work, putting it above the #header-bg. Width is set at 600px, and margin: 0 auto; centers it.
The #header is a simple div which has a height set to it and the background it requires.
Content follows the #header in normal flow.
Here is a jsfiddle with the requested behaviour.
http://jsfiddle.net/sg3s/cRZxN/
This even degrades nicely and lets you scroll horizontally if the content is larger than the screen (something I noticed from the original jsfiddle).
Edit:
To make it IE7 compatible I made some changes to fix 2 bugs. I had to add left: 0; and top: 0; explicitly to #header-bg to fix a positioning bug. Made the divs inside #header-bg 49% instead of 50% or else IE7 would not resize them properly and make the right div bump down. To compensate for the small gap that created I made the right div float: right;.
So I want to make the background of my website two tone. What I mean is have a dark gray in the center, going all the way down, but then have a lighter gray on just the sides. Maybe 80-85% of the pages width.
Do would I go about doing this?
So what I want is the middle to be one color, and the two sides to be another color. Is there a way to set the bgcolor and then set it's width to 80% or something like that?
You'd be much better off using a background image, mate; assuming you know your target audience's primary monitor size, you could just make, say, a 1024x1 image with the parameters you require. If, however (and this is more likely the case), you are trying to get this to be dynamic, why not just use a div element, like so:
<style type="text/css">
#main
{
width: 84%;
background-color: #666666;
border: 1px solid #cccccc;
border-width: 0 8% 0 8%;
}
</style>
<div id="main">#content#</div>
I take that back... Really?! No percentage widths for borders?
If you're center area is of fixed width, then you can produce an image with that width, one pixel high, and then write the following CSS:
body {
background-color: #ccc;
background-image: url('some-image.jpg');
background-position-x: center;
background-repeat: repeat-y;
}
If not, you'll have to define a <div>. Odds are you'll have to define a <div> to hold your content anyway, if you want your content to be centered on page...
CSS
<style type="text/css">
body { background-color: #ccc; }
div.page { margin: 0 auto; width: 85%; background-color: #ddd; }
</style>
HTML
<div class="page">
<h1>Your page</h1>
<p>Coming soon...</p>
</div>
No. You'll need to create an element with the dark gray background separately from the light gray element.
Something like:
<body style="background-color:#ccc;">
<div style="margin:0 auto;background-color:#555;width:85%;">
<!-- rest of the page contents -->
</div>
</body>
Or use a background image on the body, but that's less scalable, and can't be used for percentage width.