Center multiple DIV:s - html

Having trouble centering some logos. I tried to used margin: auto as well as text-align: center but can't seem to get it working.
JSfiddle

would you like something like this?
I add this class
#footer-container {
width: 100%;
display: inline-block;
text-align: center;
}
and made some changes in this class ( ex: remove the float )
.button-circle {
display: inline-block;
width: 66px;
height: 50px;
padding: 0px;
margin-top: 20px;
margin-right: 50px;
}

It will looks like this .I think that it is your desire result!

Try:
#footer-container{
text-align:center;
}
.button-circle:last-of-type{ /*remove right margin from last div*/
margin-right:0;
}
.button-circle {
display: inline-block;
}
NOTE:
inline-block adds white-space between elements. Write elements on same line to remove white-space.
Write:
<div class="button-circle">.........</div><div class="button-circle">...
Instead of:
<div class="button-circle">
.......
</div>
<div class="button-circle">
.......
</div>
DEMO here.

I have given both the code html and css check it
<div id="footer-container">
<div id="followicon">
<div class="button-circle">
<div class="bild"><img src="http://i.imgur.com/1faoLxr.jpg" style="width: 66px"></div>
<div class="block">facebook</div>
</div>
<div class="button-circle">
<div class="bild"><img src="http://i.imgur.com/hVdiFAx.jpg" style="width: 66px"></div>
<div class="block">twitter</div>
</div>
<div class="button-circle">
<div class="bild"><img src="http://i.imgur.com/WJGtp0A.jpg" style="width: 66px"></div>
<div class="block">vimeo</div>
</div>
</div><!--end of the followicon -->
</div>
<div>
//css code
#footer-container {
width:100%;
height:200px;
border:1px solid #000;
}
#followicon {
position:relative;
width:350px;
height:200px;
margin:0px auto;
}
.block{
position:relative;
width: 66px;
height: 25px;
top:0px;
z-index:100;
opacity: 0;
margin-top: -5px;
text-align: center;
text-transform:uppercase;
}
.button-circle {
display: inline;
float: left;
width: 66px;
height: 50px;
padding: 13px;
margin-top: 20px;
margin-right: 10px;
margin-left:13px;
}
.bild {
position:relative;
height: 100%;
top: 0px;
}

Related

Box inside a box / CSS + DIV

I'm trying to learn css and html to do something, but isn't working.
I'm trying to do something like this:
But this is what i'm getting:
My code:
#agenda1 { width: 350px; height: 50px; background-color: white; } #agenda2{ height: 23px; background-color: #bf1a17; border-radius: 10px; margin-top: 10px; width: 60; } #textoagenda{ text-align: center; }
<div id="agenda1"> <div id="agenda2" float="left"> <div id="textoagenda"> 26/25 </div </div> </div>
Just wrap the numbers in an element and make it inline-block so that it will display inline with the text but you can apply vertical padding, border-radius for rounded corners, padding as you see fit, a background-color, and vertical-align so it will align properly with the text beside it.
span {
background: #c00011;
border-radius: .75em;
padding: .25em .5em;
vertical-align: baseline;
display: inline-block;
}
<span>26/25</span> TESTTESTASDFASDF
add margin property your main div.
#agenda1 { width: 350px;
height: 50px;
background-color: white;
margin:auto; }
#agenda2{ height: 23px;
background-color: #bf1a17;
border-radius: 10px;
margin-top: 10px;
width: 60; }
#textoagenda{
text-align: center; }
<div id="agenda1"> <div id="agenda2" float="left"> <div id="textoagenda"> 26/25 </div </div> </div>
Here you go, try this
<html>
<head>
<style>
#box1{
position:relative;
float:left;
width: 100px;
height: 100px;
background-color: green;
}
#box2{
position:relative;
float:left;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<div id="box1">contents</div>
<div id="box2">contenst</div>
</body>
</html>

How to make a div take no horizontal space

I have a div on the top.
< div class="ad-top">
< img class="adtop" src="images.jpg" height="90" width="728"/>
< /div>
I have tried this code below
.ad-top{
padding: 0;
height: 90px;
width: 728px;
margin:0px 100px 0px 100px;
border: 1px solid black;
float: left;
}
but it still takes horizontal space to the right and pushes the advertisement on the right below. How to fix it?
This is the code for advertisement on the right.
div.ad-right{
height: 600px;
width: 300px;
margin-right: 50px;
float: right;
}
And this is the code for the section. (Note = the divs for advertisements are not children of the section.)
section{
padding-left: 50px;
display: inline-block;
}
section div{
width: 900px;
}
section div p{
text-align: left;
padding-bottom: 50px;
}
Hi now remove float left to your class .ad-top and add display:inline-block; and vertical-align:top; and define your img tag vertical-align:top as like this .
.ad-top{
float:none;
border: solid 1px black;
display:inline-block;vertical-align:top;
}
.ad-top img{
vertical-align:top;
}
Demo code is
div.ad-right{
height: 600px;
width: 300px;
margin-right: 50px;
float: right;
}.ad-top{
padding: 0;
height: 90px;
width: 728px;
margin:0px 100px 0px 100px;
border: solid 1px black;
display:inline-block;vertical-align:top;
}
.ad-top img{
vertical-align:top;
}section{
padding-left: 50px;
display: inline-block;
}
section div{
width: 900px;
}
section div p{
text-align: left;
padding-bottom: 50px;
}
<div class="ad-top">
<img class="adtop" src="https://www.gravatar.com/avatar/9b4f9deed7c1533d605bc3efb42e3604?s=32&d=identicon&r=PG&f=1" height="90" width="728"/>
</div>
Add parent div like wrapper or container which contain static width that include both ads width including margins and also give margin: 0 auto; for the parent div.
<div style="margin:0 auto;width:1278px; ">
<div class="ad-top"></div>
<div class="ad-right"></div>
</div>
Seems to me that your problem is the order of your elements. Because your "ad-right" div comes after the content section, it begins at the same height.
Here is an updated version where I have changed the order of the elements.
In summary, it is like this now:
<div class="ad-top">
<img class="adtop" src="http://dummyimage.com/728%20x%2090" height="90" width="728" />
</div>
<div class="ad-right">
<img class="adbig" src="http://dummyimage.com/300%20x%20600" height="600" width="300" />
</div>
<section><!--content--></section>
Update/add below css code:
.middle-container{
margin:0 auto; width:1132px;
}
.ad-top {
padding: 0;
height: 90px;
width: 728px;
margin:0px 100px 0px 0px;
border: 1px solid black;
display: inline-block;
vertical-align: top;
}
div.ad-right {
height: 600px;
width: 300px;
float: right;
}
section {
padding-left: 50px;
}
section div {
width: 100%;
}
And follow below html structure in your code:
<div class="container">
<div class="header"></div>
<div class="middle-container">
<div class="ad-top"></div>
<div class="ad-right"></div>
<section></section>
<footer></footer>
</div>
</div>

Aligning the inline block elements from top

How do I make two (or more) floating divs appear like "big buttons" and let them float and be leveled? My problem is that the boxes are "partially leveled"... with one slightly lower than the other. I have tried to use float: left on the adminBox, but then they grow outside the container. Can anyone help me?
I have used this HTML code:
(http://jsfiddle.net/jf936/13/)
<div class="container">
<div class="adminBox">
<h2>Manage users</h2>
<div class="adminBoxLargeContent" data-bind="text: usersCount"></div>
<div class="adminBoxSmallContent">Registered users</div>
</div>
<div class="adminBox">
<h2>Manage templates</h2>
<div class="adminBoxLargeContent" data-bind="text: templateCount"></div>
</div>
and this style:
.container{
background-color: light-blue;
}
.adminBox{
height: 200px;
width: 200px;
background-color: green;
color: white;
border-radius: 7px;
padding: 7px;
display: inline-block;
margin: 5px;
}
.adminBox h2{
color:white;
font-size:20px;
text-align:center;
}
.adminBoxLargeContent{
font-size: 70px;
text-align:center;
padding: 0;
margin: 0;
line-height: 1;
}
.adminBox .adminBoxSmallContent{
float: none;
text-align:center;
}
This has nothing to do with float, the issue is that you are using display: inline-block; and hence the element are aligned to the baseline, inorder to fix this, you need to use vertical-align: top;
Demo
.adminBox{
height: 200px;
width: 200px;
background-color: green;
color: white;
border-radius: 7px;
padding: 7px;
display: inline-block;
margin: 5px;
vertical-align: top; /* Add this here */
}
Note: You don't have to use float: none; as nothing is floated here, so you can get rid of those unused properties.
Here you go.
WORKING DEMO
The CSS Code Change:
.adminBox{
height: 200px;
width: 200px;
background-color: green;
color: white;
border-radius: 7px;
padding: 7px;
display: inline-block;
margin: 5px;
float:left;
}
Hope this helps.
Maybe this code will be helpful for you:
jsfiddle
.container{
background-color: light-blue;
overflow:hidden;
}
.adminBox{
height: 200px;
width: 200px;
background-color: green;
color: white;
border-radius: 7px;
padding: 7px;
display: block;
margin: 5px;
float:left;
}
.adminBox h2{
color:white;
font-size:20px;
text-align:center;
}
.adminBoxLargeContent{
font-size: 70px;
text-align:center;
padding: 0;
margin: 0;
line-height: 1;
}
.adminBox .adminBoxSmallContent{
text-align:center;
}
<div class="container">
<div class="adminBox">
<h2>Manage users</h2>
<div class="adminBoxLargeContent" data-bind="text: usersCount"></div>
<div class="adminBoxSmallContent">Registered users</div>
</div>
<div class="adminBox">
<h2>Manage templates</h2>
<div class="adminBoxLargeContent" data-bind="text: templateCount"></div>
</div>
</div>

How to align floated elements to the bottom of their container

Simple question, but I'm struggling with solution.
Jsfiddle here.
How can I get the title and date to both align to the bottom of the container, while ensuring that:
The length of the title will push the date across (but doesn't need to wrap)
The blue button is always centrally aligned between the date and the red icon
The titleBar container is always the same fixed height
Need a CSS-only solution if possible - I already know how to do this with JS if needed
HTML:
div class="titlebar bgEarth0">
<h1 id="title">Test Title</h1>
<h2 id="date">23 October 2013</h2>
<div class="icon"></div>
<div class="buttonArea">
<div class="button"></div>
</div>
</div>
CSS:
.titlebar { height: 50px; border:1px solid #000}
#title {font-size: 20px; font-weight: normal; float: left; margin:0}
#date { font-size: 12px; font-weight: normal; float: left; margin-left: 30px; margin:0 12px}
.buttonArea {position:relative; overflow:auto; height:40px; margin-top:5px}
.button {margin:0 auto; width:60px; height:40px; background:#0000ff}
.icon {float:right; background:#ff0000; height:40px; width:60px; margin-top:5px}
http://jsfiddle.net/hC236/
You can use absolute position.
Wrap title and date with a div and set its position to absolute.
HTML:
<div class="titlebar bgEarth0">
<div class="bleh">
<h1 id="title">Test Title</h1>
<h2 id="date">23 October 2013</h2>
</div>
<div class="icon">ddd</div>
<div class="buttonArea">
<div class="button"></div>
</div>
</div>
CSS:
.titlebar {
height: 50px;
border:1px solid #000;
position: relative;
}
.bleh {
position: absolute;
bottom: 0px;
left: 0px;
}
#title {
font-size: 20px;
font-weight: normal;
float: left;
margin:0
}
#date {
font-size: 12px;
font-weight: normal;
float: left;
margin-left: 30px;
margin:0 12px
}
.buttonArea {
position: absolute;
overflow:auto;
height:40px;
top:5px;
right: 0px;
}
.button {
margin:0 auto;
width:60px;
height:40px;
background:#0000ff
}
.icon {
background:#ff0000;
height:40px;
width:60px;
margin-top: 5px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
OR Table Example:
http://jsfiddle.net/hjM56/
HTML:
<div class="titlebar">
<div class="col-1">
<h1 id="title">Test Title</h1>
<h2 id="date">23 October 2013</h2>
</div>
<div class="col-2">
<div class="icon"></div>
</div>
<div class="col-3">
<div class="button"></div>
</div>
</div>
CSS:
.titlebar {
display: table;
height: 50px;
border: 1px solid #000;
width: 100%;
}
.col-1,
.col-2,
.col-3 { display: table-cell; }
.col-1 {
white-space: nowrap;
vertical-align: bottom;
width: 1%;
}
.col-2 {
text-align: center;
width: auto;
}
.col-3 {
text-align: right;
width: 1%;
}
#title {
font-size: 20px;
font-weight: normal;
display: inline-block;
margin: 0px;
padding: 0px;
}
#date {
font-size: 12px;
font-weight: normal;
margin-left: 12px;
margin-top: 0px;
margin-right: 12px;
margin-bottom: 0px;
display: inline-block;
padding: 0px;
}
.button {
width: 60px;
height: 40px;
background: #0000ff;
margin-top: 5;
display: inline-block;
}
.icon {
background: #ff0000;
height: 40px;
width: 60px;
margin-top: 5px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
Here is one way to do it but it involves some extra mark-up.
I added some wrappers around the title and date as follows:
<div class="titlebar">
<div id="titleArea">
<div id="table-wrap">
<div id="table-cell">
<h1 id="title">Test Title</h1>
<h2 id="date">23 October 2013</h2>
</div>
</div>
</div>
<div class="icon"></div>
<div class="buttonArea">
<div class="button"></div>
</div>
</div>
Apply the following CSS:
.titlebar {
height: 50px;
border:1px solid #000
}
#titleArea {
height:40px;
margin-top:5px;
float: left;
}
#table-wrap {
display: table;
height: 100%;
}
#table-cell {
display: table-cell;
height: 100%;
vertical-align: bottom;
}
#title {
font-size: 20px;
font-weight: normal;
padding:0;
display: inline;
}
#date {
font-size: 12px;
font-weight: normal;
padding-left: 12px;
display: inline;
}
.buttonArea {
position:relative;
overflow:auto;
height:40px;
margin-top:5px;
border: 1px dotted blue;
}
.button {
margin:0 auto;
width:60px;
height:40px;
background:#0000ff
}
.icon {
float:right;
background:#ff0000;
height:40px;
width:60px;
margin-top:5px;
border: 1px dotted blue; /* for demo only */
}
See demo at: http://jsfiddle.net/audetwebdesign/5NDDQ/
I created an outer wrapper #titleArea that has the same height and top margin as the #buttonArea.
Within #titleArea, I created a CSS table/table-cell (two nested div's) so that I can get the vertical alignment to be at the bottom.
Finally, I set display: inline to #title and #date.
A detail that may need adjustment involves the base line of the title and time. The bottom leading causes the text to sit slightly above the bottom edge of the button.
It seems like a lot of work for what appears to be a relatively simple requirement.
To make this a bit more bullet-proof, I would add a min-width to the .titlebar to prevent the .buttonArea to develop a horizontal scroll bar and the .icon from wrapping to a second line.
You shouldn't use floating unless necessary. See this JSFiddle Live Demo
Basically if you remove the floats and display:inline-block; instead, they will align. I also removed the overflow:auto, as that would limit the icon area.
Also, adding left:15%; will align the blue area between the date and the red area.
EDIT: Example with max-width specifications to contain the div inside the title bar. Live Demo

how to create following divs?

Sorry but having difficulty in creating a group of div as attached pic..please help
http://imgur.com/J8psv
my biggest problem is having to get the divs arranged next to each other inside of parent divs. Infact to go to a next level, if there is a 5th div of 200px then I want it to automatically come to the second line.
I understand I need something to do with CSS, just that am not so well versed with it.
.div_main_left {
width: 800px;
border: 1px solid;
height: 600px;
float: left;
display: table-cell;
}
.div_sec_left {
width: 200px;
border: 1px solid;
height: 75px;
display: inline;
float: left;
}
.div_right {
width: 250px;
border: 1px solid;
height: 500px;
float: right;
display: table-cell;
}
You can do it like this:
HTML
<div id="mainwrapper">
<div id="leftwrapper">
<div class="topbox"></div>
<div class="topbox"></div>
<div class="topbox"></div>
<div class="topbox"></div>
<div id="maincontent"></div>
</div>
<div id="rightwrapper">
<div id="topsidebar"></div>
<div id="bottomsidebar"></div>
</div>
</div>
CSS
#mainwrapper{
width:1050px;
}
#rightwrapper{
width:250px;
float:left;
}
#leftwrapper{
width:800px;
float:left;
}
.topbox{
float: left;
width:196px;
margin-right:4px;
height:75px;
background-color:orange;
}
#maincontent{
width:100%;
height:675px;
background-color:blue;
clear:both;
}
#topsidebar
{
width:100%;
height:600px;
background-color:green;
}
#bottomsidebar{
width:100%;
height:150px;
background-color:red;
}
Here is the jsfiddle
Do it in a list then style the list itself. From: http://www.alistapart.com/articles/taminglists/
#tabs ul {
margin-left: 0;
padding-left: 0;
display: inline;
}
#tabs ul li {
margin-left: 0;
margin-bottom: 0;
padding: 2px 15px 5px;
border: 1px solid #000;
list-style: none;
display: inline;
}
#tabs ul li.here {
border-bottom: 1px solid #ffc;
list-style: none;
display: inline;
}
You can start with this:
Fiddle Example
First the html:
<div id="container">
<div class="big_left">
<div class="float_parent">
<div class="small">200x75</div>
<div class="small">200x75</div>
<div class="small">200x75</div>
<div class="small">200x75</div>
</div>
<div class="content">
The Content;
</div>
</div><!-- Big left End -->
<div class="big_right">
<div class="right_long">
250x750
</div>
</div><!-- Big Right End -->
</div>
Then the css:
#container {
width:1065px;
}
.big_left {
width:810px;
float:left;
}
.big_right {
width:255px;
float:left;
}
.big_left .float_parent {
width:800px;
}
.big_left .float_parent .small{
width:200px;
height:75px;
float:left;
}
.big_left .content {
clear:both;
}
.big_right .right_long {
width:250px;
height:750px;
}