Divs overlapping parent divs - html

I have a contact us page with several divs that act as containers and inside these containers are more divs that hold the content. Here is the structure of the page :
<div class="divBlock">
<div class="spacer10"></div>
<div class="centerDiv">
<div>
<div class="divContactImg">
<div class="branchHeader">Durban</div>
<div class="branchText">89 Joe Slovo Street</div>
<div class="branchText">Durban</div>
</div>
<div class="divContactImg">
<div class="branchHeader">Hillbrow</div>
<div class="branchText">Point Building</div>
<div class="branchText"> StreetG</div>
<div class="branchText">Hillbrow</div>
</div>
<div class="divContactImg">
<div class="branchHeader">Pinetown</div>
<div class="branchText">56 Hill Street</div>
<div class="branchText">Pinetown</div>
</div>
</div>
</div>
</div>
</div>
<div class="spacer10"></div>
</div>
The problem is these divs (divContactImg) are overlapping their container div (divBlock). Here is the CSS:
.centerDiv { text-align : center; max-width : 100%; height : auto; margin: 0px auto 0px auto; display: block ; }
.divContactImg {
background-image: url('Images/Contacts_Branches_BG.png');
width:220px;
height:74px;
border-left: thin solid #333;
border-top: thin solid #333;
border-right: thin solid maroon;
border-bottom: thin solid maroon;
float:left;
text-align:left;
margin-left: 10px;
margin-top: 1px;
border-radius:5px;
}
.branchHeader {
font-size: 24px;
font-family:Arial Narrow;
margin-left: 10px;
margin-top: 5px;
text-transform:uppercase;
text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 00 #000;
}
.branchText {
font-size: 12px;
color:#b0b0b0;
margin-left: 10px;
text-transform:uppercase;
}
.branchHeaderOpening {
font-size: 24px;
font-family:Arial Narrow;
margin-left: 10px;
margin-top: 5px;
text-transform:uppercase;
text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 00 #000;
text-align:center;
}
.divBlock { border-left: thin solid #333; border-right: thin solid #333; border-bottom: thin solid #333; border-radius: 0px 0px 8px 8px;
margin: 0px 10px 0px 10px; background: #000000;}
I have tried setting clear:both on the container divs but no luck. If I take out the float:left then the center div stretches so the children div's fill it, however I need these divs to be displayed three across and this makes them display one per line.

I replaced
.divContactImg {
background-image: url('Images/Contacts_Branches_BG.png');
width:220px;
height:74px;
border-left: thin solid #333;
border-top: thin solid #333;
border-right: thin solid maroon;
border-bottom: thin solid maroon;
/*float:left;*/
display:inline-block; **/**ADD**/**
vertical-align:top; **/**ADD**/**
text-align:left;
margin-left: 10px;
margin-top: 1px;
border-radius:5px;
}

Related

How can I get a border to work correctly html

So i'm butting a border around a div like so
#menu{
margin: 0px;
padding: 100px 0px 0px 20px;
float: left;
border-bottom: 1px solid black;
border-right: 1px solid black;
border-top: 1px solid black;
border-radius: 0px 10px 10px 0px;
}
<div id="menu">
<p>Hello</p>
</div>
But the border ignores the padding or something as can be seen on the image
Image
According to CSS Box Model Border is right in between margin and padding.
CSS Box Model
I am not sure exactly how do you want your design to be but, you can try that shorthand property you used in padding, in margin, Like this:
#menu{
margin: 100px 0px 0px 20px;
padding: 5px;
float: left;
border-bottom: 1px solid black;
border-right: 1px solid black;
border-top: 1px solid black;
border-radius: 0px 10px 10px 0px ;
}
I hope this is what you want.
A simple example is below. for further clarifications visit w3schools
<p class="round3">Roundest border</p>
p.round3 {
border: 2px solid red;
border-radius: 12px;
}
Try these values:
#menu{
margin: 0px;
padding: 100px 0px 0px 20px;
//padding: top right bottom left
float: left;
border: 1px solid black;
border-radius: 10px ;
}
Try this, this is working for me
#menu p{
text-align: center;
margin: 0 auto;
border: 1px solid black;
padding: 50px;
border-radius: 20px;
width: 300px;
}
<div id="menu">
<p>Hello</p>
</div>
If the padding has four values:
padding:10px 5px 15px 20px;
This means:
- top padding is 10px
- right padding is 5px
- bottom padding is 15px
- left padding is 20px
And similar is for border-radius:
border-radius: 15px 50px 30px 5px;
(first value applies to top-left corner, second value applies to top-right corner,third value applies to bottom-right corner, and fourth value applies to bottom-left corner)
So you can try this:
#menu {
margin: 0px;
padding: 100px 0px 0px 20px;
float: left;
border: 1px solid black;
border-radius: 10px;
}

CSS Auto top div

Need your help about simple css question :
How to auto top div using display: inline block and vertical-align: top with my case below?
The css here :
vertical-align: top;
display: inline-block;
width: 194px;
background: #fff;
border-left: 1px solid #c0c0c0;
border-right: 1px solid #c0c0c0;
border-top: 1px solid #c0c0c0;
border-bottom: 1px solid #c0c0c0;
word-wrap: break-word;
padding: 10px;
margin-top: 5px;
-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);box-shadow:0 0 5px 0 rgba(0,0,0,0.2);
text-align: left;
and here is the fiddle
Help much appreciated...
Use multiple columns:
<div class="content_wall_column">
<div class="content_wall">...</div>
<div class="content_wall">...</div>
</div>
<div class="content_wall_column">
<div class="content_wall">...</div>
</div>
See my JSFiddle.
change your css for class content_wall like this
.content_wall
{
vertical-align: top;
display: inline-block;
width: 194px;
background: #fff;
border-left: 1px solid #c0c0c0;
border-right: 1px solid #c0c0c0;
border-top: 1px solid #c0c0c0;
border-bottom: 1px solid #c0c0c0;
word-wrap: break-word;
padding: 0px;
margin-top: 0px;
-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);box-shadow:0 0 5px 0 rgba(0,0,0,0.2);
text-align: left;
}
Removed the margin and the padding;
Demo Fiddle
or even better
give the padding first then remove the top padding
like this
.content_wall
{
vertical-align: top;
display: inline-block;
width: 194px;
background: #fff;
border-left: 1px solid #c0c0c0;
border-right: 1px solid #c0c0c0;
border-top: 1px solid #c0c0c0;
border-bottom: 1px solid #c0c0c0;
word-wrap: break-word;
padding: 10px;
padding-top:0px;
margin-top: 0px;
-webkit-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);-moz-box-shadow:0 0 5px 0 rgba(0,0,0,0.2);box-shadow:0 0 5px 0 rgba(0,0,0,0.2);
text-align: left;
}
Fiddle for this
Remove margin-top: 5px from .content_wall, but you probably don't want them to touch each other, so don't remove it, but change it to margin-bottom: 5px.
Then add following to your stylesheet:
body, html {
margin: 0;
padding: 0;
}
Check the updated fiddle

Remove the border where two division intersect

I am attaching two division's border and remove the border where two division intersect but its not remove. I have tried this code.
<div style="border:solid 1px #CCC;
margin: 15px 0px 0px 350px;
border-bottom:none;
padding:12px 12px 8px 12px;
border-radius:5px 5px 0px 0px;
width:300px;
text-align:center;">
<strong style="font-size:18px; color:#000">ABC</strong>
</div>
<div style="width:968px;
float:left;
margin:0px 15px 15px 15px;
border: solid 1px;
border-color:#CCC;
border-radius:10px;">
Hello
</div>
Can anybody help me to solve this error.
jsFiddle: http://jsfiddle.net/9XFDp/1/
Just nudge the top div by 1px from top and use some background-color or even border-bottom is fine
Demo
Added the below properties to the header div
position: relative;
top: 1px;
background: #fff;
z-index: 1;
Note: Don't use inline CSS, create classes instead.
Demo 2 (Without using background-color, used border-bottom: 1px solid #fff; instead)
Like this
DEMO
CSS
.title{
border:solid 1px #CCC;
margin: 15px 0px 0px 350px;
border-bottom:1px solid #ffffff;
padding:12px 12px 8px 12px;
border-radius:5px 5px 0px 0px;
width:300px;
text-align:center;
font-size:18px; color:#000
font-weight:bold;
position:relative;
top:1px;
}
.content{
width:968px;
float:left;
margin:0px 15px 15px 15px;
border: solid 1px;
border-color:#CCC;
border-radius:10px;
}

Center Div Expanding Border

I'm working on an image grid and want to create an effect similar to this http://instagram.com/instagram/ (the images in the squares on the lower part of the page where the border expands. This is what I have so far:
HTML:
<div id="page-title"> </div>
<div id="wrapper" style="min-height:300px;">
<!--start: Container -->
<div class="container" style="margin-left:100px;">
<div style="position: absolute; width:200px; border: 1px solid black; height:200px;">
<div style="position: relative; background:url('/testimages/1354189822.jpg')" class="polaroids">
</div>
</div>
</div>
</div>
</div>​
CSS:
.polaroids {
background: #fff;
float: left;
width: 158px;
height:158px;
padding: 5px 5px 5px;
text-align: center;
text-decoration: none;
color: #333;
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.25);
-moz-box-shadow: 0 3px 6px rgba(0,0,0,.25);
-webkit-transition: all .2s ease-in-out;
border: 4px solid white;
background-color: black;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
margin:0 auto !important;
}
.polaroids:hover {
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.5);
-moz-box-shadow: 0 3px 6px rgba(0,0,0,.5);
z-index: 5; border-top: 10px solid white;
border-bottom: 10px solid white;
border-left: 8px solid white;
border-right: 8px solid white;
}​
The middle div does not seem to want to centre. Where am I going wrong? http://jsfiddle.net/b5XDK/​​​
for horizontal center use margin:0 auto; on the child element and remove the float:left;
http://jsfiddle.net/roine/b5XDK/10/
remove this
.polaroids { float:left }
remove your float:left of .polaroids

CSS Margin problem

I'm starting out in HTML and CSS.
I have a div element on the page, which doesn't fill the whole page.
In it- there's a ul element and some list items in it.
I want to put the list 227px from the top of the div element, but I can't manage to accomplish this- it pushes it more.
Also- between the list items I want a margin of 40 pixels, but it also does more.
What's the problem?
Here's my code:
Html:
<body>
<div class="Hashta">
<div class="Menu">
<ul id="MenuItems">
<li><a href="#" >ONE</a></li>
<li><a href="#" >TWO</a></li>
<li><a href="#" >THREE</a></li>
<li><a href="#" >FOUR</a></li>
</ul>
</div>
</div>
</body>
CSS:
body {
background-color: Gray;
}
.Hashta{
width:874px;
height:650px;
background-color:black;
margin: auto auto 50px auto;
border-radius: 20px;
border: 3px solid darkgray;
moz-box-shadow: 2px 2px 10px black;
webkit-box-shadow: 2px 2px 10px black;
box-shadow: 2px 2px 10px black;
}
.Menu {
margin-top: 227px;
padding-right: 50px;
float:right;
}
#MenuItems {
list-style:none;
}
#MenuItems li {
text-align:center;
position:relative;
padding: 4px 10px 4px 10px;
margin-right:30px;
margin-bottom: 40px;
border:none;
}
#MenuItems li a{
width: 280px;
height: 70px;
background-color: green;
color:White;
font-family:Arial, Helvetica, sans-serif;
font-size:24px;
display:block;
outline:0;
text-decoration:none;
text-shadow: 1px 1px 1px #000;
line-height: 70px;
}
If you want to measure the pixels- you can install this: http://www.mioplanet.com/products/pixelruler/
(click to rotate)
Thanks!
You should start your styling by resetting all elements so that each browser shows them identical.
You can check one of the many CSS reset libraries around there, but for starting something like this would be already good:
* {
margin: 0;
padding: 0;
}
This, appearing for first in your CSS stylesheet, will remove all margins and paddings for each element, so you can add them later only in the elements you want.
Update
If you want to restore some element margins or paddings after that code (for example in body) simply write a new rule after the one before, like
body {
padding:10px; /* Add 10px to body only */
}
The total height of every list item is height + padding + border + margin.
Change the padding of #MenuItems li into:
padding: 0 10px 0 10px;
See http://jsfiddle.net/NGLN/rBjrD/1/
Add margin:0; padding:0 for body
In #MenuItems li replace:
padding: 4px 10px 4px 10px;
with:
margin: 4px 10px 4px 10px;
This will make the distance equal to 40px between buttons.
Try absolute positioning:
.Hashta{
width:874px;
height:650px;
background-color:black;
margin: auto auto 50px auto;
border-radius: 20px;
border: 3px solid darkgray;
moz-box-shadow: 2px 2px 10px black;
webkit-box-shadow: 2px 2px 10px black;
box-shadow: 2px 2px 10px black;
position:relative;
}
.Menu {
position:absolute;
top:227px;
right:0;
padding-right: 50px;
float:right;
}
try this:
<style>
body {
background-color: Gray;
}
.Hashta{
width:874px;
height:650px;
background-color:black;
margin: auto auto 50px auto;
border-radius: 20px;
border: 3px solid darkgray;
moz-box-shadow: 2px 2px 10px black;
webkit-box-shadow: 2px 2px 10px black;
box-shadow: 2px 2px 10px black;
}
.Menu {
margin-top: 227px;
padding-right: 50px;
float:right;
}
#MenuItems {
list-style:none;
}
.secLi{
text-align:center;
position:relative;
padding: 0px 10px 0px 10px;
margin-right:30px;
margin-top: 40px;
border:none;
}
.firstLi{
text-align:center;
position:relative;
padding: 0px 10px 0px 10px;
margin-right:30px;
margin-top: -16px;
border:none;
}
#MenuItems li a{
width: 280px;
height: 70px;
background-color: green;
color:White;
font-family:Arial, Helvetica, sans-serif;
font-size:24px;
display:block;
outline:0;
text-decoration:none;
text-shadow: 1px 1px 1px #000;
line-height: 70px;
}
</style>
<body>
<div class="Hashta">
<div class="Menu">
<ul id="MenuItems">
<li class="firstLi"><a href="#" >ONE</a></li>
<li class="secLi"><a href="#" >TWO</a></li>
<li class="secLi"><a href="#" >THREE</a></li>
<li class="secLi"><a href="#" >FOUR</a></li>
</ul>
</div>
</div>
</body>