I am currently learning how to slice a theme and i would like some help on positioning a div under other divs. For example i would like to position the divs (box1-box3) under the AdSales&Announcements divs and for them to be centered. If you notice on the fiddle the divs are not centered ad the other divs. Thanks in advance.
<div id="AdSales">
</div>
<div id="Announcements">
</div>
<div id="Box1"></div>
<div id="Box2"></div>
<div id="Box3"></div>
http://jsfiddle.net/edwinakatosh/YjLCe/embedded/result/
wrap the three div in a wrapper div. you need to remove the top: style of your div, so the wrapper can do its job
HTML
</div>
<div id="Announcements"></div>
<div class="wrapper">
<div id="Box1" class="box"></div>
<div id="Box2" class="box"></div>
<div id="Box3" class="box"></div>
</div>
CSS
#adSales, #Announcements{top:0}
.box{top:0; }
.wrapper{width:780px; margin:0 auto; overflow:hidden}
margin: 0 auto center aligns none floated divs. overflow: hidden recalculates floated child divs. width: 780px is the total width of the wrappers child divs plus the margin
http://jsfiddle.net/feitla/YjLCe/1/
Wrap a div around it
<div id="AdSales"></div>
<div id="Announcements"></div>
<div id="container">
<div id="Box1"></div>
<div id="Box2"></div>
<div id="Box3"></div>
</div>
And give it a width and position it
#container {
margin:0 auto;
position:relative;
width:950px;
}
Related
See the attachment.
I have 6 logos at the top and 7 logos at the bottom that sticks out of the screen. How to create the bottom div to be non-responsive?
Add a fixed width on it. In pixels.
width: 700px;
Update:
Remove these divs from the page to get the desired effect:
<div class="partner-divider"></div>
You'd need to set the display property to: inline-block
<div style="display: inline-block">Text</div>
If you change your mind and want it responsive:
HTML:
<div id="myDiv"> Content </div>
CSS:
#myDiv
{
min-height: 100%;
max-height: 100%;
}
References:
How to make div not larger than its contents?
Make div NOT auto stretch to container width
Div 100% height of page responsive
Hope this will help you something like this.
<div class="col-md-6">
<div style="width: 500px;">
<div class="box" id="A"></div>
<div class="box" id="B"></div>
<div class="box" id="C"></div>
<div class="box" id="D"></div>
<div class="box" id="E"></div>
<div class="box" id="F"></div>
<div class="box" id="G"></div>
<div class="box" id="H"></div>
<div class="box" id="I"></div>
</div>
</div>
I have the following problem: I'm working on this site and using a picture as a background of 1 div. Inside this div I have another 2 dives - logo and navigation.
Last /outside of the div with the picture/ is the footer, whos background must be other color, not the picture. I set the css to the div with the picture like this :
#background{
position: absolute;
z-index: -1;
display: block;
}
Here is the html :
<div id="pic">
<img id="background" src="picture.jpg">
<div class="row" id="logo">
</div>
<div class="row" id="example-menu">
</div>
</div>
<div class="row" id="footer">
<div class="medium-3 columns medium-offset-1" id="worktime">РАБОТНО ВРЕМЕ: </br> ПОНЕДЕЛНИК-ПЕТЪК </br> 08:30-19:00ч.</div>
<div class="medium-8 columns"></div>
</div>
But the problem is that the footer also goes over the div with the picture and my design is not like this... I need to keep the whole picture to be seen.
Thanks in advance !
the issue is with the z-index of the div containing the image and the div containing the footer.
the easiest solution is to put the footer after the div with your content. The only time z-index should come into play is if you are trying to put items on top of the image for effect.
<div id="content-wrapper">
<div id="nav">
<span>NAV</span>
</div>
</div>
<div id="footer">
<span>FOOTER</span>
</div>
you can easily add the footer in the container, attach at the bottom as well.
see if this example helps:
https://plnkr.co/edit/GDfzul2qKApw6JGhQSbb?p=preview
Option 1
Instead of using <img>, put the background using CSS
HTML
<div id="pic">
<div class="row" id="logo"></div>
<div class="row" id="example-menu"></div>
</div>
<div class="row" id="footer">
The footer content
</div>
CSS
#pic{
background: url( 'picture.jpg' ) no-repeat;
}
Option 2
Use fixed height for the parent div, #pic in this case:
HTML
<div id="pic">
<img id="background" src="picture.jpg">
<div class="row" id="logo"></div>
<div class="row" id="example-menu"></div>
</div>
<div class="row" id="footer">
The footer content
</div>
CSS
#pic{
position: relative;
height: 100px; /* This should be the height of the background image */
}
#background{
position: absolute;
z-index: -1;
}
Option 3
You may use position:absolute for the .rows instead:
#pic{ position: relative; }
.row{ position: absolute; top: 0; z-index: 99; }
<div id="pic">
<img id="background" src="https://placehold.it/200x100">
<div class="row" id="logo">This is logo</div>
</div>
<div id="footer">
The footer content
</div>
I'm confused at a basic problem, and I'm not sure how to go about this --
Take a look at www.hncharity.com
If you look at the content div, it's slightly off center (It becomes more pronounced as you go into mobile view).
The div is structured like so:
<div class="container">
<div class="span10 offset1">
<div class="content">
....
</div>
</div>
</div>
The .content class has a white background, adds padding, and a margin all around the span10 offset1 div, to make the width appear smaller.
This is the css for content
margin:40px;
padding:40px;
position:relative;
margin-top:-200px;
z-index:1201;
background-color:white;
As you can see, the content does not appear to be centered. What would I do to fix this?
you missed to add a container with class row before span and after container.
Correct way:
<div class="container">
<div class="row">
<div class="span10 offset1">
<div class="content">
....
</div>
</div>
</div>
</div>
I want to vertically center <div id="innner"> inside <div id="outer">, when the contents of <div id="innner"> are dynamically generated, and thus variable in height. That is,
<div id="outer">
<div id="inner">
// dynamically generated stuff
</div>
</div>
#outer{
float:left;
height:50%;
margin-bottom:-120px;
}
#inner{
clear:both;
height:240px;
position:relative;
}
HTML
<div id="outer">
<div id="inner">
Content here
</div>
</div>
<div style="float:left">
<div class="designerWrapper">
<div class="pageBox">
content
</div>
</div>
</div>
<div style="float:left; margin-left:10px;">
content 2
</div>
<div style="clear:both"></div>
<br /><br />
How do I make the div that holds content 2 100% width? If I set it to 100% width it is too wide, at the moment it expands with it's contents length.
you sould use the table stuff
<div id="outer1">
<div id="outer2">
<div id="left"></div>
<div id="right"></div>
</div>
</div>
css:
#outer1 {display:table;width:600px;height:30px;}
#outer2 {display:table-row;width:600px;height:30px;}
#left {display:table-cell; width:15px;}
#right {display:table-cell; width:auto;}
important there is no floating! because the table display floats the cells automatically.
i didnt test the code hope works.
You can set min-width depend upon your requirement.
later on it will expand with its content
<div style="float:left; margin-left:10px;min-width:110px;">
content 2
</div>