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

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>

Related

Full width block near floated one

I have two rows like this
<div class="container me">
<div class="message">
</div>
<div class="time">
</div>
</div>
<br />
<div class="container he">
<div class="message">
</div>
<div class="time">
</div>
</div>
with css like this
* {
padding:0;
margin:0;
}
.container {
width:500px;
height:50px;
outline:1px solid green;
}
.message {
width:250px;
height:50px;
border:1px solid red;
display:inline-block;
border-radius:5px;
position: relative;
}
.time {
width:50px;
height:50px;
background:orange;
}
.container.me .time {
float:right;
}
.container.he .time {
float:left;
}
and i am trying to make message block full possible width (100% minus time block), is it possible?
jsfiddle https://jsfiddle.net/Nerfair/t0t0q632/5/
You can set width for .message to width: calc(100% - 52px); - this 52px is a width of your .time div (50px) + 2px for borders of .message (left and right)
Edit: For IE8 support you cannot use that, so you can try the tricky thing like this: https://jsfiddle.net/L2pqhnsq/

Partitioned image in a table

I need to cut an image in Photoshop and to recompose it. I thought to create a table / div-table where put the pieces of the partitioned image.
I have done this:
<div id="Table">
<div id="row">
<div id="col">
<img src="01.png" alt="">
</div>
<div id="col">
<img src="02.png" alt="">
</div>
<div id="col">
<img src="03.png" alt="">
</div>
</div>
<div id="row">
<div id="col">
<img src="04.png" alt="">
</div>
<div id="col">
<img src="05.png" alt="">
</div>
<div id="col">
<img src="06.png" alt="">
</div>
</div>
<div id="row">
<div id="col">
<img src="07.png" alt="">
</div>
<div id="col">
<img src="08.png" alt="">
</div>
<div id="col">
<img src="09.png" alt="">
</div>
</div>
</div>
with Css:
<style type="text/css">
<!--
img {
width: 100%;
height: auto;
}
#Table {
display: table;
width: 50%;
}
#row {
display: table-row;
}
#col {
display:table-cell;
}
-->
</style>
UPDATE:
I have to add in the middle (img 5) a table with the items, the quantity and the price. I have updated the fiddle. There are some problems in the fiddle but here there are the link with the screenshot of my page.
https://www.dropbox.com/s/sxa2ug1vz5lcdml/schermata7.png?dl=0
JSFIDDLE:
http://jsfiddle.net/wdb5gq29/43/
I'm working on a similar project (responsive image map), and I found positioned divs placed over a single image to be much more stable.
It has the added advantage of being used as an image map, because you can put content in or add functionality to the 9 divs, use more or less divs, and there are no alignment issues because it uses one image versus multiple sliced images. An awesome example is the responsive image map at CSS Play: http://www.cssplay.co.uk/menu/cssplay-responsive-image-map.html
Here is the code for an example similar to yours.
JSFiddle
HTML
<div id="wrapper">
<div class="image-holder">
<img src="http://i.imgur.com/3bhQPx0.jpg" class="image-background" />
<div class="hotspot-container">
<div id="L01">1</div>
<div id="L02">2</div>
<div id="L03">3</div>
<div id="L04">4</div>
<div id="L05">5</div>
<div id="L06">6</div>
<div id="L07">7</div>
<div id="L08">8</div>
<div id="L09">9</div>
</div>
</div>
</div>
(Note: The CSS is written out in long form as an example for easier use. It would be shortened down on a live site by combining the similar styles.)
html{
height:100%;
width:100%;
margin:0;
padding:0;
border:none;
}
body {
height:100%;
width:100%;
margin:0;
padding:0;
border:none;
}
#wrapper {
height:100%;
width:100%;
}
.image-holder {
width:50%;
position:relative;
}
.image-background {
width:100%;
display:block;
}
.hotspot-container {
height:100%;
width:100%;
position:absolute;
top:0;
left:0;
}
#L01 {
width:33%;
height:33%;
position:absolute;
left:0%;
top:0%;
border:solid 1px #000000;
}
#L02 {
width:33%;
height:33%;
position:absolute;
left:33%;
top:0%;
border:solid 1px #000000;
}
#L03 {
width:33%;
height:33%;
position:absolute;
left:66%;
top:0%;
border:solid 1px #000000;
}
#L04 {
width:33%;
height:33%;
position:absolute;
left:0%;
top:33%;
border:solid 1px #000000;
}
#L05 {
width:33%;
height:33%;
position:absolute;
left:33%;
top:33%;
border:solid 1px #000000;
}
#L06 {
width:33%;
height:33%;
position:absolute;
left:66%;
top:33%;
border:solid 1px #000000;
}
#L07 {
width:33%;
height:33%;
position:absolute;
left:0%;
top:66%;
border:solid 1px #000000;
}
#L08 {
width:33%;
height:33%;
position:absolute;
left:33%;
top:66%;
border:solid 1px #000000;
}
#L09 {
width:33%;
height:33%;
position:absolute;
left:66%;
top:66%;
border:solid 1px #000000;
}
Remember to add !DOCTYPE html, or IE will have issues. Also, the div widths are set at 33% with a border to highlight the structure. On the live version, you'll delete the borders and try setting the horizontal divs to 33.333%, equaling to 100%. Or 33% 34% 33%.
For your original CSS table layout, you can add the following additional CSS to stabilize the table and remove the default bottom gap under the images, and it worked in Firefox and Explorer, but showed the odd gap or alignment issues in other browsers at various screen sizes.
.table {
display:table;
width:50%;
margin:0;
padding:0;
border-width:0;
border-style:none;
border-collapse:collapse;
}
.col {
display:table-cell;
border:none;
}
.image {
width:100%;
height:auto;
border:0px;
vertical-align:bottom;
}
Updated Redesign Using a Flexable Image Background
According to your latest Fiddle, it looks like you would like to display a data table, with the printer image as a background. The JSFiddle example below has a flexible container div set at the requested 50%. Within the container is the data table, and an absolutely positioned printer image that scales, and serves as the background.
JSFiddle
.price-container {
position:relative;
padding:0;
display:table;
width:50%;
}
.image-bg {
display:block;
position:absolute;
top:0;
left:0;
min-height:100%;
/* min-width:300px; - setting is helpful if the distortion at smaller sizes is bothesome, set here and on table-holder - width of the actual image */
width:100%;
height:auto;
margin:0;
padding:0;
z-index:-1;
}
.table-holder {
z-index:2;
padding:2em;
/* min-width:300px; */
}
.printer-display-table {
width:100%;
padding:0;
border-width:0;
border-style:none;
border-collapse:collapse;
font-family:verdana;
font-size:.6em;
}
.printer-display-table td {
border:solid 1px #000000;
padding:.5em;
}
HTML
<div class="price-container">
<img src="http://i.imgur.com/wurCt2y.jpg" class="image-bg" />
<div class="table-holder">
<table class="printer-display-table">
<tr><td>Item</td><td>Q</td><td>Price</td></tr>
<tr><td>BlaBlaBla</td><td>1</td><td>50</td></tr>
<tr><td>Eve</td><td>Jackson</td><td>94</td></tr>
<tr><td>Item</td><td>Q</td><td>Price</td></tr>
<tr><td>BlaBlaBla</td><td>1</td><td>50</td></tr>
<tr><td>Eve</td><td>Jackson</td><td>94</td></tr>
</table>
</div>
</div>
Add display: block and remove width from your img tag to get rid of the cellspacing:
img {
display: block;
height: auto;
}
updated fiddle: http://jsfiddle.net/wdb5gq29/42/

2 floating divs on top of 2 centered divs

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;
}

CSS inline-block alignment issue

I'm trying to get the pictures to get ".other-wrap" to vertically align with the picture on the left. I've tried adding a margin or a border but for some reason this pushes ".other-wrap" down and further out of alignment. Can anyone explain what's causing this behavior and what css I can add to ".other-wrap" to get it to align without changing the html structure.
fiddle
Html:
<div id="588970897807405-list" class="main">
<div id="588970897807405" class="main-wrap">
<div class="inner-wrap">
<div class="inner-name-wrap" style="font-size: 10pt;">
<div class="inner-name">header</div>
</div>
<div class="inner-img-wrap">
<img id="588970897807405-event-img" class="inner-img" src="http://nodogaboutit.files.wordpress.com/2012/10/j04310181.jpg">
</div>
<div class="formatted-footer-wrap" style="font-size: 10pt;">
<div class="footer">footer</div>
</div>
</div>
<div class="other-wrap">
<div class="other-inner">
<div class="other-img-wrap"><img class="other-img" width="120" height="120" src="http://www.petfinder.com/wp-content/uploads/2012/11/99059361-choose-cat-litter-632x475.jpg"></div>
</div>
</div>
</div>
CSS:
.main .inner-img{
vertical-align:middle;
margin:auto;
display:block;
width:120px;
height:120px;
top:0px;
}
.other-wrap{
/*border:solid black 15px;*/
margin:15px;
}
.main .inner-name-wrap{
white-space:nowrap;
width:150px;
font-size:14px;
text-overflow:ellipsis;
font-weight:normal;
display:block;
color:white;
background:black;
}
.main .formatted-footer-wrap{
color:white;
display:block;
font-size:10px;
width:150px;
background:black;
}
.main .other-wrap{
display:inline-block;
font-size:12px;
}
.main .formatted-time-wrap{
display:none;
font-size:10px;
}
.inner-wrap{
display:inline-block;
border:solid hsl(0, 100%, 100%) 1px;
}
It seems you need vertical-align.
Try vertical-align: middle:
.main-wrap{
font-size: 0; /* To fix extra space due to whitespaces in HTML */
}
.other-wrap, .inner-wrap{
display:inline-block;
vertical-align: middle;
margin: 15px;
}
Demo

DIVs inside another DIV inside another DIV with CSS

Here's what I'm trying to achieve:
This is the HTML code I wrote:
<div id="wrapper"> <!--This is the Div 1 in the picture-->
<div id="topBar"> <!--This is the Div 2 in the picture-->
<div id="logo"></div> <!--This is the Div 4 in the picture-->
<div id="menu"></div> <!--This is the Div 5 in the picture-->
<div id="login"><!--This is the Div 6 in the picture-->
<div class="loginElement"><input type="text" id="txtUsername" class="loginElementBox" size="29" value="User name" onClick="usernameFocus()" onBlur="usernameBlur()" /></div>
<div class="loginElement">
<input type="text" name="txtFakePassword" id="txtFakePassword" class="loginElementBox" value="Password" onfocus="passwordFocus()" /><input style="display:none;" type="password" id="txtPassword" class="loginElementBoxFocus" onBlur="passwordBlur()" />
</div>
<input type="button" id="btnLogin" value="" onclick="login()"><br />
<span id="lblError"></span>
</div><!--Closing "login"-->
</div><!--Closing "topBar"-->
<div id="central"> <!--This is the Div 3 in the picture-->
<div id="top3"> <!--This is the Div 7 in the picture-->
</div>
</div><!--Closing "central"-->
</div><!--Closing "wrapper"-->
and this is the CSS:
#wrapper
{
width:800px;
background-color:#f2f2e8;
position:relative;
left:50%;
margin-left:-400px;
border-radius: 10px;
-moz-border-radius: 10px;
padding:5px;
}
#topBar
{
width:780px;
border: 1px solid;
border-color: #dbd9ca;
border-radius: 10px;
-moz-border-radius: 10px;
margin:5px;
padding:5px;
}
#logo
{
width:153px;
height:66px;
background-image:url(../images_ui/logo2.png);
background-repeat:no-repeat;
background-position:left center;
margin:5px;
padding:5px;
float:left;
}
#menu
{
float:left;
width:400px;
position:relative;
}
#login
{
float:right;
width:80px;
}
#central
{
width:780px;
border: 1px solid;
border-color: #dbd9ca;
border-radius: 10px;
-moz-border-radius: 10px;
margin:5px;
margin-top:20px;
padding:5px;
}
Inside Div 6 I have a few more Divs
It all just comes out scrambled. Div 2 and Div 3 look OK inside Div 1, and Div 7 looks nice inside Div 3, but once I add Divs 3, 4, 5... I tried several things, with float, position etc - nothing worked, I can't arrange it as I want it. Any ideas how to make it work?
#Div1
{
width:800px;
margin:0 auto;
overflow:hidden;
float:left;
}
#Div2
{
width:100%;
float:left;
}
#Div3
{
width:100%;
clear:both;
}
#Div4, #Div6
{
float:left;
width:30%;
}
#Div5
{
float:left;
width:40%;
}
#Div7
{
width:70%;
margin:50px auto;
}
If I haven't forgotten something that should be round about it

Resources