I would like to write up some css/html for container boxes that I can put on my site in various places (ie- to draw out modules like a calendar on the site's sidebar).
I have 5 images: left, right, top, bottom and background for the div.
The top image is 37 px tall, the bottom image is 22 px tall.
I would ideally like to specify a div height/width and then have it draw the div with the images on the top/bottom/right/left sides, autosized to the div's proportions and not overlapping with each other. I would assume that youd want to use absolute positioning for the non-overlapping bit, but I'm completely unsure of how to make the images resize and stick to each side.
Here's the (very bare) code that I have right now:
#top {background: url(container_top.png) no-repeat;}
#container {background: url(container_left.png) no-repeat;}
#right {background: url(container_right.png) no-repeat;}
#bottom {background: url(container_bottom.png) no-repeat;}
<div id="top">
<div id="container">
Content post
</div>
<div id="right"></div>
<div id="bottom"></div>
</div>
The only other caveat is that I only want the top/bottom images to scale horizontally (not to resize on the y axis as well), and the left/right images to scale vertically (not to resize on the x axis as well).
For reference, my images are named:
"container_.png"
there are a few options. First one is to create four corner divs and four side divs, using the corner images at each corner and a repeatable image for the sides. You can also use a kind of "sliding-door" technique. And if you're a brave guy, use css3 border-images (checkout http://w3schools.com/cssref/css3_pr_border-image.asp)
option one:
<div class="box">
<div class="top">
<div class="top-left"></div>
<div class="top-right"></div>
</div>
<div class="content">
<div class="left"></div>
<div class="content">Lorem ipsum dolor sit amet</div>
<div class="right"></div>
</div>
<div class="bottom">
<div class="bottom-left"></div>
<div class="bottom-right"></div>
</div>
</div>
.top { background: url('repeatable.png') repeat-x; }
.top-left { background: url('top-left.png') no-repeat; }
.content .left { background: url('repeatable') repeat-y; }
....
for sliding door technique, checkout http://www.google.com/?q=google+css+sliding+doors
Related
I'm having trouble with aligning a container-fluid within bootstrap. I've attached a screenshot of what I'm trying to achieve. The list items on the bottom left should align with the text at the top (which is contained in a container). The newsletter section on the bottom right (red background) should span the entire width from the center to the edge of the screen. The content within the newsletter section should also be aligned with the text at the top.
Here's what I currently have for the code at the bottom:
<div class="container-fluid">
<div class="col-md-12">
<div id="footer" class="col-md-6">
<ul>
<li>About Us</li>
<li>Consumers</li>
<li>Sites</li>
<li>Operators</li>
<li>Contact Us</li>
</ul>
</div>
<div id="newsletter" class="col-md-6">
<h4>Subscribe to our newsletter to receive the latest news about Poqeta </h4>
</div>
</div>
Thanks for any suggestions!
bootstrap-grid
You can wrap your footer in a div that you give a background that is half of the screen width, either using CSS gradients (if your only concern is modern browsers) or with absolutely positioning elements or images. See this answer for more information. Then within this "footer wrapper" you place a container, and within this container you define your columns. For each column you set the background color again. This will "overlay" the background color of the footer within the container.
<div class="footer">
<div class="container">
<div class="col-sm-8 left">
left section, list items
</div>
<div class="col-sm-4 newsletter">
newsletter section
</div>
</div>
</div>
.footer {
background: linear-gradient(90deg, #ffffff 50%, #ff0000 50%);
}
.left {
background: #ffffff;
}
.newsletter {
background: #ff0000;
}
See this fiddle for an example, you may want write some CSS for mobile (depending on what breakpoint you use for column wrapping, -sm, -md or -lg)
Change
<div class="container-fluid">
to
<div class="container">
To make background full page, try this:
<div class="container-fluid">
<div class="container">
...
</div>
</div>
You can make "padding: 0" on "container-fluid" or "container" to make it straight
i want to create an html page ,where on the left top side will be an image (400x200) ,exact below the image a rectangle div(same width with image and height 50px) and exact on the right of the image another rectangle as a button(same height with image an width 50px) .
On the right size of the page i want 3 smaller rectangle divs as buttons(100x50) (one next to the other).
How can i achieve this? .I thought of creating two containers and put the image and the 2 divs to the one on the left and the rest 3 divs to the right.
However something is missing, especially if the resolution is lower or i adjust the window the arrangement is awful .Which approach is better when the resolution is smaller. The position should be for the left container absolute?Thanks in advance.
I 've created this
#container1 {width:50%;height:300px;float:left;margin-left:30px;margin-top:20px;}
#container1 a{ text-decoration:none;}
#container2 {width:40%;height:300px;float:right;margin-left:50px;margin-top:50px;}
#container2 a{ text-decoration:none;}
#col1 { float:left; margin:5px;font-size:14pt; border:1px;width:400px;height:200px;border-radius:5px;}
.col2 { float:left;background-color:rgb(17, 83, 151); margin:10px; border:1px ;margin-top:75px;width:155px;height:70px;}
#col3 { position:relative;float:left;background-color:rgb(17, 83, 151); margin:5px;margin-right:5px;font-size:14pt; border:1px ;width:110px;height:200px;border-radius:5px;}
.int {text-align:center;border 1px;font-family:segoe UI;font-size:14pt;color:white;padding-top:5px;margin:15px;}
.int2 {text-align:center;border 1px;font-family:segoe ui;font-size:14pt; color:white;padding-top:50px;margin:3px;}
#col4 {position:absolute;float:left;clear:both;background-color:rgb(17, 83, 151); margin:5px;font-size:14pt; border:1px ;width:400px;height:80px;border-radius:5px;}
.button {padding-top:30px; padding-left:10px; color:white; font-size:10pt; font-family:Segoe UI; text-decoration:none;}
<div id="container1">
<div id="col1" class="col">
<img id="img" src="http://ima.gs/transparent/400x200.png"">
</div>
<div id="col3">
<div class="int2">button 1</div>
</div>
<div id="col4">
<div class="int">button 2 </div>
</div>
</div>
<div id="container2">
<div class="col2"><div class="button">button 3</div>
</div>
<div class="col2"><div class="button" style="padding-top:30px;">button 4</div>
</div>
<div class="col2"><div class="button" style="padding-top:30px;">button5</div>
</div>
</div>
The first thing I'm noticing is that you're floating elements and using margins. Switch to padding and this will make your life much easier as far as width calculations goes:
#container1 {width:50%;height:300px;float:left;padding-left:30px;margin-top:20px;}
#container2 {width:50%;height:300px;float:right;padding-left:50px;margin-top:50px;}
As long as border-box is being used in your css, padding eats up the inside of containers instead of adding it to the outside. Basically your containers were 50% + 30px margin. I changed it to 50% width with an inset 30px padding. Now you can do easy math instead of accounting for a margin.
I have the following split among 3 main div to be side by side. The very left div I want it to take up 60% of the screen and the rest 2 (description and resource) to take each 20%. When I run this all 3 are overlapping on the left portion. Below is my codes.
<div id="left" style="position:absolute;top:0px;left:0px;width:60%;height:100%;background:#e6e6e6;">
<div id="map" style="position:absolute;top:0px;left:0px;width:60%;height:400px">Map goes here.</div>
<div id="details" style="position:absolute;top:400px;left:0px;width:60%;height:400px">Details</div>
</div>
<div id="description" style="position:absolute;top:0px;width:20%;height:100%;background:#ffffff;">
</div>
<div id="resource" style="position:absolute;top:0px;width:20%;height:100%;background:#ffffff;">
</div>
They are overlapping because you've given them all absolute position and left 0. Absolute position removes the element from the normal flow of the page and puts it exactly where you indicate using the top/left/right/bottom properties. They will overlap as long as they have the same parent and same position properties.
Absolute position and left being 0 is making them overlap.
Please use css
see solution : http://jsfiddle.net/thecbuilder/vZ77e/
html
<div id="left">
<div id="map">Map goes here.</div>
<div id="details">Details</div>
</div>
<div id="description">description</div>
<div id="resource">resource</div>
css
#left, #description, #resource{
display:inline;
float:left;
height:100%;
}
#left{
width:60%;
background:#e6e6e6;
}
#description, #resource{
width:20%;
}
They are overlapping because you are using position absolute. instead place the divs at the top of the html page and do this instead:
<div id="left" style="float:left;width:60%;height:100%;background:#e6e6e6;">
<div id="map" style="float:left;width:60%;height:400px">Map goes here.</div>
<div id="details" style="float:left;left:0px;width:60%;height:400px">Details</div>
</div>
<div id="description" style="float:left;width:20%;height:100%;background:#ffffff;">
</div>
<div id="resource" style="float:left;width:20%;height:100%;background:#ffffff;">
</div>
This will place the divs beside each other
I have a row with content which should be in the center of the site and a footer at the bottom. The content are divided into two 6 column. i want it to center align vertically according to the screen size. so i tried to give some percentage of top with a position relative but it doesn't work out.
If i give margin-top it is working. In order to make the top we have to give the position, so i have given it relative I don't want position absolute then the footer will come at the top of the site. Other content also will come top i thnik.
How to center align the contents and footer should stay at bottom all time all display size.
HTML
<div class='row'>
<div class='col-md-6 vertical'> content</div>
<div class='col-md-6 vertical'>content right</div>
</div>
<footer>sit at bottom</footer>
CSS
.vertical{
position:relative;
/* margin-top:20%; */ /*works*/
top:20%; /*not works even providing position */
}
JSFIDDLE NOTE: Don't forgot to resize the window then only you can able to see the two column division
<div class='row'>
<div class='col-md-6 '>
<div class="vertical"> content</div>
</div>
<div class='col-md-6 '>
<div class="vertical"> content</div>
</div>
</div>
<footer>sit at bottom</footer>
.vertical{
display: table-cell;
vertical-align:middle;
height: 200px /* Accordingly */
}
Working Fiddle Fiddle.
Apart from using display: table-cell, there is one more way to do it but is not so cross-browser at this moment. Take a look at CSS3 Flexbox.
I'm new at this so bear with me. I have an absolute positioned box inside a relative container and inside that box I've two other divs, one for posts and one for sprites. The sprites completely disappear in IE7 along with the top (and only the top) border on the "posts." This is basically what it looks like.
<div id="wrapper">
<div id="content">
<div id="left"></div>
<div id="right">
<div id="icon">
</div><!--icon-->
<div id="posts">
<div class="posts_border"></div>
<!--a bunch of other stuff-->
<div class="posts_border"></div>
</div>
</div><!--right-->
</div><!--content-->
</div>
#wrapper{width:900px;margin-top:111px;margin-left:-450px;position:relative;left:50%;}
#content{background-color:#F6EFC9; position:relative; width:900px;height:965px;}
#left{padding-right:10px;width:550px;}
#right{position:absolute;top:0;right:20px;width:300px;}
#icon{margin:10px 0 0 -8px;top:0;right:20px;}
#icon .icon{margin-left:40px;width:50px;height:50px;float:left;}
#email{background:url("../images/icon-sprite.png")left 0 top -110px;}
#twitter{background:url("../images/icon-sprite.png") left 0 top -55px;}
#rss{background:url("../images/icon-sprite.png") left 0 top 3px;}
#posts{background:#E3C66E; margin-top:10px;position:absolute;top:66px;}
#right .posts_border{height:20px;background-color:#442503;}
http://jsfiddle.net/isherwood/aJwKJ/
This seems to work in every browser aside from IE7.
I had to do this in IE10 by changing my Browser/Document mode to IE7/IE7 on a local document. I had problems with jsfiddle loading in that browser/doc mode. I only changed the following sections
#email {
background-image: url("http://placehold.it/32x32");
background-position: 0 -110px;
}
#twitter {
background:url("http://placehold.it/32x32");
background-position:0,-55px;
}
#rss {
background:url("http://placehold.it/32x32");
background-position:0,3px;
}