2 floating divs on top of 2 centered divs - css

I'm trying to create something that will allow me to put something on top of images in this case, small images.
basically, it goes like this and both main divs are centered:
http://jsmith.elementfx.com/images/questions.png
tia.
Sorry, here is
HTML
<div id="container">
<div id="left"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="leftimage"><h2>963</h2></div>
<div id="right"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="rightimage"><h2>434</h2></div>
</div>
CSS
#container{
margin:0px auto;
width:320px;
text-align:center;
margin-bottom:20px;
}
#left {
float:left;
margin-left:15px;
margin-right:20px;
position:relative;
}
#leftimage{
position:absolute;
padding-top:2px;
margin-left:5px;
width:65px;
}
#right {
margin-right:15px;
}
#rightimage{
position:absolute;
padding-top:2px;
width:65px;
}

you have to use z-index and position to acheive it,
DEMO
HTML
<div id="container">
<div id="left"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="leftimage"><h2>963</h2></div>
<div id="right"><div id="rightimage"><h2>434</h2></div><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
</div>
CSS
#container{
margin:0px auto;
width:320px;
text-align:center;
margin-bottom:20px;
}
#left {
float:left;
margin-left:15px;
margin-right:20px;
position:relative;
}
#leftimage{
position:absolute;
padding-top:2px;
margin-left:5px;
width:65px;
z-index:1;
}
#right {
position:relative;
margin-right:15px;
}
#rightimage{
margin-left:175px;
position:absolute;
z-index:1000;
}

use this code, the calculation of the width and height of images would be according to your images:
HTML
<div class="container">
<div class="img1">
<img src="https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png" width="32" height="32" />
</div>
<div class="img2">
<img src="https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png" width="32" height="32" />
</div>
</div>
CSS
.container{
width:270px;
margin:0 auto;
overflow:hidden;
}
.img1,.img2{
width:128px;
height:128px;
background:url(https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png);
float:left;
margin-right:10px;
border:1px solid #000;
}
.img2{margin:0;}
DEMO jsfiddle for this

Demo Fiddle - Quad view with 3 layered images
<div class="container start">
<img src="http://www.placehold.it/300/555555"></img>
<div id="base1" class="base">
<img src="http://www.placehold.it/200/654321"></img>
<div id="overlay1" class="overlay">
<img src="http://www.placehold.it/100/123456"></img>
</div>
</div>
</div>
.base {
width: 200px;
height: 200px;
position: relative;
top: -290px;
left: 10px;
}
.overlay {
width:100px;
height:100px;
position: relative;
left: 10px;
top: -190px;
}
.container {
left:100px;
width: 300px;
height: 300px;
margin: 10px;
float: left;
}
.start {
clear: left;
}

Related

Horizontally centering and spacing with css

I want to produce an image gallery style page for a responsive web site.
Depending on device and orientation the page displays between 1 and 4 images horizontally.
How can I achieve this and ensure that:
The space between the images remains equal
Each row is centered on the page regardless of device,
orientation and the number of images.
I would appreciate any pointers, as I am new to this I may have overlooked the correct terminology while attempting to find the answer using the search feature.
Thanks for your time and consideration.
#verwrapper {
text-align:left;
width:100%;
margin-left: auto;
margin-right: auto;
padding-top:20px;
overflow: hidden;
background: none repeat scroll 0 0 #FFFFFF;
text-align:center; /* for IE */
}
.ver{
position:relative;
border-bottom:2px solid #686868;
width:200px;
height:310px;
background-color:#fff;
margin-bottom:20px;
margin:0 auto;
padding:0 0.5em;
overflow:hidden;
float:left;
}
.verbild{
position:relative;
height:200px;
width:200px;
float:left;
outline:2px solid #C0C0C0;
outline-offset: -2px;
}
<div id="verwrapper">
<div class="ver">
<div class="verbild"><img src="image1.jpg" width="200" height="200" /></div>
</div>
<div class="ver">
<div class="verbild"><img src="image2.jpg" width="200" height="200" /></div>
</div>
<div class="ver">
<div class="verbild"><img src="image3.jpg" width="200" height="200" /></div>
</div>
</div>
Nick
Use same padding for right & left side(em or %), use margin:0 auto. like that -
.test1{
margin:0 auto;
padding:0 0.5em;
}
Try this. Just change sizes as you need.
<div class="row">
<div class="image">
<img src="http://placehold.it/350x150"/>
</div>
<div class="image">
<img src="http://placehold.it/350x150"/>
</div>
<div class="image">
<img src="http://placehold.it/350x150"/>
</div>
<div class="image">
<img src="http://placehold.it/350x150"/>
</div>
</div>
<style>
.row {width: 500px; margin: 0 auto;}
.image {width: 25%; float: left;box-sizing: border-box; padding: 0 5px;}
.image img { width: 100%;}
</style>

Site name in header css?

I would put the site name in the middle of this header but unfortunately I can not do it, I've tried many combinations but I just can not. I'll post the source
CSS
.header {
background-color:#00B9ED;
height:50px;
border-bottom:0px;
padding-left:auto;
padding-right:auto;
width:100%;
}
#wrapper {
margin-left:auto;
margin-right:auto;
width:1000px;
padding-top:0px;
padding-bottom:0px;
}
.logo {
width:150px;
margin: 0 auto;
}
.logo img {
width:150px;
height:50px;
}
.logo:hover {
height:50px;
background-color:#A9E2F3;
cursor:pointer;
}
HTML
<div class="header">
<div id="wrapper">
<div class="logo">
<img src="image.png" />
</div>
</div>
</div>
have no idea how can I do? Thanks
Use Below Code
<style>
.header {
background-color:#00B9ED;
height:50px;
border-bottom:0px;
padding-left:auto;
padding-right:auto;
width:100%;
}
#wrapper {
margin-left:auto;
margim-right:auto;
padding-top:0px;
padding-bottom:0px;
}
.logo {
text-align: center;
}
.logo img {
width:150px;
height:50px;
}
.logo:hover {
height:50px;
background-color:#A9E2F3;
cursor:pointer;
}
</style>
<div class="header">
<div id="wrapper">
<div class="logo">
<a>Bhavin<img src="image.png"></a>
</div>
</div>
</div>
Always try to code with standards. You can use text-align but it is for align paragraph or other elements with text. Insted align I would recommend to use margin:0 auto;width:150px;.
Here you got jsFiddle
try this
CSS
#wrapper {
margin: 0 auto;
padding-bottom: 0;
padding-top: 0;
width: 1000px;
}
.logo {
margin: 0 auto;
width: 150px;
}
HTML
<div class="header">
<div id="wrapper">
<div class="logo">
logo<img src="image.png" alt="LOGO"/>
</div>
</div>
</div>

Please help cant center div in css, need assistance

I have exported div tags from photoshop design into dreamweaver using slices, extracted the css from head and created a style sheet. all the div tags in the page have an absolute position set for each of them. I have tried everything i can think of to center all the content on the page and nothing has worked. can someone please take a look at the code and tell me what i am missing.
<HTML>
<html>
<head>
<title>Packet Access</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/style_sheet.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-color:#FFFFFF; margin-top: 0px; margin-bottom: 0px;
margin-left: 0px; margin-right: 0px`enter code here`;">
<div id="Table_01">
<div id="topper">
</div>
<div id="Topper-2">
</div>
<div id="search">
<img src="images/search.png" width="133" height="19" alt="">
</div>
<div id="topper-side2"></div>
<div id="topper-side"></div>
<div id="Logo">
<img src="images/Logo.png" width="254" height="37" alt="">
</div>
<div id="side-logo-right"></div>
<div id="under-search"></div>
<div id="index-09"></div>
<div id="navigation">
<img src="images/navigation.png" width="457" height="20" alt="">
</div>
<div id="under-logo"></div>
<div id="under-navigation"></div>
<div id="divider">
<img src="images/divider.jpg" width="1024" height="3" alt="">
</div>
<div id="bg-left">
<img src="images/bg_left.jpg" width="131" height="147" alt="">
</div>
<div id="index-15">
<img src="images/index_15.png" width="764" height="52" alt="">
</div>
<div id="bg-right">
<img src="images/bg_right.jpg" width="129" height="147" alt="">
</div>
<div id="index-17">
<img src="images/index_17.jpg" width="764" height="243" alt="">
</div>
<div id="index-18">
<img src="images/index_18.jpg" width="130" height="519" alt="">
</div>
<div id="index-19">
<img src="images/index_19.jpg" width="1" height="148" alt="">
</div>
<div id="index-20">
<img src="images/index_20.jpg" width="1" height="148" alt="">
</div>
<div id="index-21">
<img src="images/index_21.jpg" width="128" height="519" alt="">
</div>
<div id="index-22">
<img src="images/index_22.png" width="766" height="43" alt="">
</div>
<div id="index-23">
<img src="images/index_23.png" width="12" height="1" alt="">
</div>
<div id="OTT-box">
<img src="images/OTT_box.jpg" width="242" height="99" alt="">
</div>
<div id="index-25">
<img src="images/index_25.png" width="9" height="1" alt="">
</div>
<div id="XFP">
<img src="images/XFP.jpg" width="242" height="99" alt="">
</div>
<div id="index-27">
<img src="images/index_27.png" width="10" height="1" alt="">
</div>
<div id="Cache">
<img src="images/Cache.jpg" width="242" height="99" alt="">
</div>
<div id="index-29">
<img src="images/index_29.png" width="9" height="1" alt="">
</div>
<div id="index-30">
<img src="images/index_30.jpg" width="12" height="327" alt="">
</div>
<div id="index-31">
<img src="images/index_31.jpg" width="9" height="327" alt="">
</div>
<div id="index-32">
<img src="images/index_32.jpg" width="10" height="327" alt="">
</div>
<div id="index-33">
<img src="images/index_33.jpg" width="9" height="327" alt="">
</div>
<div id="index-34">
<img src="images/index_34.png" width="242" height="81" alt="">
</div>
<div id="index-35">
<img src="images/index_35.png" width="242" height="81" alt="">
</div>
<div id="index-36">
<img src="images/index_36.png" width="242" height="81" alt="">
</div>
<div id="index-37">
<img src="images/index_37.jpg" width="242" height="148" alt="">
</div>
<div id="index-38">
<img src="images/index_38.jpg" width="242" height="148" alt="">
</div>
<div id="index-39">
<img src="images/index_39.jpg" width="242" height="148" alt="">
</div>
<div id="footer">Copyright © 2012 Packet Access</div>
</div>
<!-- End Save for Web Slices -->
</body>
</html>
<!--The CSS is below-->
<CSS>
#charset "utf-8";
*{
margin:0;
padding:0;
}
.body {
background-color: #000;
text-align:center; /*For IE6 Shenanigans*/
}
#Table_01 {
margin: 0 auto;
text-align: center;
width: 1024px;
}
#topper {
position:absolute;
left:0px;
top:0px;
width:1024px;
height:10px;
background-color:#000000;
}
#Topper-2 {
position:absolute;
left:0px;
top:10px;
width:763px;
height:6px;
background-color:#000000;
}
#search {
position:absolute;
left:763px;
top:10px;
width:133px;
height:19px;
background-color:#000000;
}
#topper-side2 {
position:absolute;
left:896px;
top:10px;
width:128px;
height:59px;
background-color:#000000;
}
#topper-side {
position:absolute;
left:0px;
top:16px;
width:130px;
height:53px;
background-color:#000000;
}
#Logo {
position:absolute;
left:130px;
top:16px;
width:254px;
height:37px;
}
#side-logo-right {
position:absolute;
left:384px;
top:16px;
width:379px;
height:26px;
background-color:#000000;
}
#under-search {
position:absolute;
left:763px;
top:29px;
width:133px;
height:13px;
background-color:#000000;
}
#index-09 {
position: absolute;
left: 384px;
top: 42px;
width: 55px;
height: 27px;
background-color: #000;
}
#navigation {
position:absolute;
left:439px;
top:42px;
width:457px;
height:20px;
background-color:#000000;
}
#under-logo {
position:absolute;
left:130px;
top:53px;
width:254px;
height:16px;
background-color:#000000;
}
#under-navigation {
position:absolute;
left:439px;
top:62px;
width:457px;
height:7px;
background-color:#000000;
}
#divider {
position:absolute;
left:0px;
top:69px;
width:1024px;
height:3px;
background-color:#000000;
}
#bg-left {
position:absolute;
left:0px;
top:72px;
width:131px;
height:147px;
}
#index-15 {
position:absolute;
left:131px;
top:72px;
width:764px;
height:52px;
}
#bg-right {
position:absolute;
left:895px;
top:72px;
width:129px;
height:147px;
}
#index-17 {
position:absolute;
left:131px;
top:124px;
width:764px;
height:243px;
}
#index-18 {
position:absolute;
left:0px;
top:219px;
width:130px;
height:519px;
}
#index-19 {
position:absolute;
left:130px;
top:219px;
width:1px;
height:148px;
}
#index-20 {
position:absolute;
left:895px;
top:219px;
width:1px;
height:148px;
}
#index-21 {
position:absolute;
left:896px;
top:219px;
width:128px;
height:519px;
}
#index-22 {
position:absolute;
left:130px;
top:367px;
width:766px;
height:43px;
}
#index-23 {
position:absolute;
left:130px;
top:410px;
width:12px;
height:1px;
}
#OTT-box {
position:absolute;
left:142px;
top:410px;
width:242px;
height:99px;
}
#index-25 {
position:absolute;
left:384px;
top:410px;
width:9px;
height:1px;
}
#XFP {
position:absolute;
left:393px;
top:410px;
width:242px;
height:99px;
}
#index-27 {
position:absolute;
left:635px;
top:410px;
width:10px;
height:1px;
}
#Cache {
position:absolute;
left:645px;
top:410px;
width:242px;
height:99px;
}
#index-29 {
position:absolute;
left:887px;
top:410px;
width:9px;
height:1px;
}
#index-30 {
position:absolute;
left:130px;
top:411px;
width:12px;
height:327px;
}
#index-31 {
position:absolute;
left:384px;
top:411px;
width:9px;
height:327px;
}
#index-32 {
position:absolute;
left:635px;
top:411px;
width:10px;
height:327px;
}
#index-33 {
position:absolute;
left:887px;
top:411px;
width:9px;
height:327px;
}
#index-34 {
position:absolute;
left:142px;
top:509px;
width:242px;
height:81px;
}
#index-35 {
position:absolute;
left:393px;
top:509px;
width:242px;
height:81px;
}
#index-36 {
position:absolute;
left:645px;
top:509px;
width:242px;
height:81px;
}
#index-37 {
position:absolute;
left:142px;
top:590px;
width:242px;
height:148px;
#index-38 {
position:absolute;
left:393px;
top:590px;
width:242px;
height:148px;
}
#index-39 {
position:absolute;
left:645px;
top:590px;
width:242px;
height:148px;
}
#footer {
position: absolute;
left: 0px;
top: 738px;
width: 100%;
height: 21px;
background-color: #000000;
font-family: "Helvetica LT Std";
font-size: 14px;
color: #999;
text-decoration: none;
text-align: center;
padding-top: 3px;
padding-bottom: 2px;
}
</style>
To answer the immediate question of how to center everything on the page, change #Table_01 from:
#Table_01 {
margin: 0 auto;
text-align: center;
width: 1024px;
}
to:
#Table_01 {
margin: 0 auto;
text-align: center;
width: 1024px;
position: relative;
}

css two div floated left . Right div not covering the remaining space

I've two divs leftSide and rightSide whose parent is innerContainer. I've floated both the divs to left.They are appearing side by side but the right div is not covering the remaining space of the parent div.
I tried using overflow:hidden and also specified the width but still it is of the same width.
My Css:
#container {
overflow:auto;
margin:10px auto;
}
#innerContainer{
margin:10px auto;
width:1200px;
background:#FFFFFF;
border:2px solid #09F;
overflow:auto;
}
#leftSide{
overflow:auto;
float:left;
width:700px;
border:3px solid #F00;
}
#topheaderProfile{
margin:5px;
border:1px solid #F00;
}
#middleCompanyDescription{
margin:5px;
border:1px solid #333;
}
#Profile{
text-align:left;
}
.ProfileBox{
padding:10px;
cursor:pointer;
overflow:hidden;
text-align:left;
word-break:break-all;
word-wrap:break-word;
}
.CompanyLogo{
float:left;
padding:5px;
}
.rightCover{
overflow:auto;
padding:1px;
}
.companyTitle{
color:#36F;
font-size:24px;
overflow:hidden;
}
.companyTitle a{
text-decoration:none;
}
.CompanyRating{
float:left;
margin-top:3px;
}
.Companylikedicon{
overflow:hidden;
float:right;
margin-left:10px;
}
.Companycommenticon{
float:right;
margin-right:10px;
}
.CompanySlogan{
color:#999;
word-break:break-all;
word-wrap:break-word;
clear:both;
}
#rightSide{
width:100px;
border:1px solid #000;
}
My Html:
<div id="container">
<div id="innerContainer">
<div id="leftSide">
<div id="topheaderProfile">
<div id='Profile'>
<div class='ProfileBox'>
<div class='CompanyLogo'><img src='../Images/defaultPic.jpg' width='90' height='90'/></div>
<div class='rightCover'>
<div class='companyTitle'>My Company</div>
<div class='CompanyRating'>
Rating : <img src='../Images/FilledStar.png' width='20' height='20' id='Star1' />
<img src='../Images/EmptyStar.png' width='20' height='20' id='Star2' />
<img src='../Images/EmptyStar.png' width='20' height='20' id='Star3' />
<img src='../Images/EmptyStar.png' width='20' height='20' id='Star4' />
<img src='../Images/EmptyStar.png' width='20' height='20' id='Star5' />
</div>
<div class='Companylikedicon'><img src='../Images/LikedIcon.png' width='25' height='25' /> 100</div>
<div class='Companycommenticon' ><img src='../Images/comment.png' width='25' height='25' /> 100</div>
<div class='CompanySlogan'>This is the best offer you get 2Rs. off in the besaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat underwear of the worldffer you get 2Rs. off in the besaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat underwear of the world.</div>
</div>
</div> <!--ProfileBox-->
</div>
</div><!--TopHeeaderProfile-->
<div id="middleCompanyDescription">
sadasdsad
</div>
</div> <!--LeftSide-->
<div id="rightSide">
sadasdasdasd
</div>
</div>
</div>
Ok I've found the problem.There is another css file containing id names same as in this file.This is causing the problem.The properties of that file are being applied here.
Thanks everyone for your help.
I tried using overflow:hidden and also specified the width but still it is of the same width.
Use overflow: hidden but don't specify any width if you want #rightSide to fill the remaining space.
See: http://jsfiddle.net/thirtydot/Yuxzs/
#rightSide {
overflow: hidden;
border: 1px solid #000;
}​
Try this:
<style type="text/css">
#rightSide {
width:100px;
border:1px solid #000;
float:left;
}
</style>

with div(width:auto) in a div(width:auto)

Hi guys I've got a problem with some div with width:auto.
Here's the HTML:
<div class="greenMenu">
<div class="btn">
<img src="img/image.png" width="57" height="46" />
<div class="area">
<div class="txt">A Lorem ipsum</div>
</div>
</div>
<div class="btn">
<img src="img/image.png" width="57" height="46" />
<div class="area">
<div class="txt">A Lorem ipsum</div>
</div>
</div>
</div>
and the CSS:
.greenMenu {
position:absolute;
top:83px;
left:220px;
width:auto;
height:47px;
background:url(../img/prod-uova-ripMenu.png) left top repeat;
}
.greenMenu .btn {
background:#090;
float:left;
margin-top:1px;
margin-left:6px;
*display:inline;
_display:inline;
width:auto;
height:43px;
position:relative;
}
.greenMenu .btn img {
border:none;
position:absolute;
top:0px;
left:0px;
z-index:2;
}
.greenMenu .btn .area {
background:#53882d;
width:auto;
height:32px;
position:absolute;
top:5px;
left:0px;
z-index:1;
}
.greenMenu .btn .area .txt {
float:left;
margin:7px 13px 0 60px;
}
The problem is: the greenMenu cannot expand its width and in the same time div.btn width is 0.
Don't use following code there:
position: absolute;

Resources