Display table css float to right - css

I have 2 table-cell as demo below. I wanted to make the left block (white block) to place in right place and the right block in the left place without removing table-cell.
The idea is I want to put the white block on the top of black block in responsive. Just like the float left and float right.
Here is the Jsfiddle Demo
Thanks!

You have to include float:left and float:right to the layers and include the property box-sizing:border-box to the style .table-cell
https://jsfiddle.net/MAXXALANDER/mgpu4nqs/3/
.table-cell{
display:table-cell;
width:50%;
padding:5px;
box-sizing:border-box;
}

Related

Css pseudo-elements alignment

I have the following fiddle, not able to align the image using :after in my case, it is not as bad as in fiddle, but it is touching the horizontal line more towards the bottom of the box foreach div instead of aligning with the text inside div.
http://jsfiddle.net/pT7vX/
Just change your position to relative, and tone down the padding. At least I assume this is more what you're after.
div.lnk:after {
background:image;
content: ">";
position:relative;
padding:5px;
background-repeat:no-repeat;
}
http://jsfiddle.net/pT7vX/1/
hope this helps.

How to position overflown 'divs' side by side

DEMO HERE
I have two divs in a container. Both divs have 100% and 100% height. How do I position those divs side by side?
I tried float:left and display:inline-block but nothing seems to work. Second div is always under first div, not side by side
P.S. I don't want to use absolute position and I want one div overflown.
If both of them has 100% width you can't get the second one side by side. You should use "width: 50%" in those divs (I suppose they didn't have margins or padding), and then "float:left" the first one. The second one should go to the right of the first one.
If you want to add both div side by side you can not set div width 100%, you can set width 50% to check both are side by side without using display:inline-block
.innerDivs{
width:50%; // Change 100% to 50%
height:100%;
float:left;
}
Check this Demo
You should add overflow:hidden; property in outer div to solve this
Check this Demo
HTML
<div style="width:300px;height:100px;border:3px solid black;margin-top:100px;margin-left:100px;overflow:hidden;">
<div class="innerDivs" style="background:orange"></div>
<div class="innerDivs" style="background:red"></div>
</div>
CSS
.innerDivs{
width:100%;
height:100%;
float:left;
}

div box within another div

This should be really simple, and I thought I was doing it correctly...evidently not.
I need to get the light grey box that says "Test" into the darker grey area, to the right of the list on the left. It's supposed to be 270px tall (or whatever) and stretch to the right edge of the list on the left, and to the edge of the enclosing container on the right side.
Here's a Fiddle with my code. Easy peasy. Thanks, guys and gals.
There are two approaches to solving the problem, which stems from your use of float: right. You can either 1) Move the .theater gray box above the sidebar, and it will properly float to the right side of it, or 2) You can change the sidebar to float: left, remove the float from the gray box, and add a left margin.
Here's an example of the second approach.
You could also float both the sidebar and the gray box, but I would not suggest that.
You need to float:left or otherwise take the .revision-gutter div out of the flow
Floated left in my example: http://jsfiddle.net/trapper/f8yLh/1/
Just add float:left; to the .revision-gutter and your done!
YOUR CSS SHOULD BE
.revision-gutter {
width:270px;
height:inherit;
background-color:#333333;
overflow-y:scroll;
float: left;
}
And he updated Fiddle!
add float: left; to your revision-gutter class, and that should get you started.

Wrappers size reflecting its contents

Take a look at this Fiddle.
I'm puzzled as to why #wrapper doesn't expand to accommodate the divs inside it. What's missing here?
As a side note, any idea as to why my <hr> isn't displaying properly?
The wrapper doesn't expand because the items inside are floating and taken out of the natural flow of the document.
You can tell the wrapper to expand past the floating elements by adding a block level element to the end of the wrapper and telling it to clear all floats:
#wrapper:after{
content:".";
display:block;
clear:both;
visibility:hidden;
}
Also, you had the height of the wrapper set to 100px.
Here's an updated version of your fiddle: http://jsfiddle.net/kWJ79/9/
As for your hr, what exactly are you wanting to do? It looks like you're wanting to create a vertical bar between the 2 divs. Is this correct?
UPDATE
If you're wanting to create a line between the left and right divs I'd consider a slightly different route.
What I'd do is put the left div inside its own container which has a right padding, margin and border. This way you don't have a redundant div floating around in your code and recudes the need to use a hr.
Here's an updated fiddle with this example: http://jsfiddle.net/kWJ79/15/
#left_wrapper{
margin-right:5px;
padding-right: 5px;
border-right:1px solid red;
float:left;
}
Notice that I've removed the float:left; from the #left div and placed it on the #left_wrapper instead.
You have specified the height value.

How position divs horizontally inside another div

I have a php script that is generating an unspecified number of divs inside another but by default the divs are being vertically aligned as in one of top of the other though their widths can allow for them to be horizontally aligned. How can i go about this?
div > div{
display: inline-block;
}
float them to left
float:left;
or give them inline display mode.
display:inline;

Resources