[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

margin problem

Posted on 2011-02-21
6
Medium Priority
?
805 Views
Last Modified: 2012-05-11
hi
maybe i have stopped thinking but i do not get what is wrong.

i have a div id= containet
and inside that div a div class= initialbox.

when i give margin-top to the initialbox it is the container that moves. i want to move the inner div and untouch the outer div.

best regards
0
Comment
Question by:derrida
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 11

Expert Comment

by:level9wizard
ID: 34943777
This might be a sign of the 'containet' div (you mentioned) or it's parent having invalid styles  - can you provide us some source code to look at? Below is a simple example that does exactly what you're asking for.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
  <title>example</title>
  <style type="text/css">
	div.Main{
		width:500px;

		border: 2px solid red;
	}
	#inner{
		border: 2px solid green;
		margin-top: 100px;
	}
  </style>
</head>

<body>

<div class="Main">
	<div id="inner">
		Hello World
	</div>	
</div>

</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:derrida
ID: 34944036
hi

i made a test myself so its very clean but still does not work fine.

i attach my code.

hope you can see what i am doing wrong.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">

        #container{
            width: 960px;
            height: 600px;
            background-color: wheat;
            
}

#container .initialbox{
    width: 300px;
    height: 300px;
    background-color: red;
    margin-top: 5em;
}

    </style>

  </head>
  <body>
    <div id="container">
        <div class="initialbox">this is the box</div>
    </div>
  </body>
</html>

Open in new window

0
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 2000 total points
ID: 34948240
Change  your page style to

 
  #container{
            width: 960px;
            height: 600px;
            background-color: wheat;
			padding:5em 0 0 0;
}

#container .initialbox{
    width: 300px;
    height: 300px;
    background-color: red;
}

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:derrida
ID: 34948929
hi

jagadishdulal obviously your code does work but it does not use the margin property, and that is my issue. i try to see WHY margin does not work.

it kills me but i cannot see why level9`s example does work and mine does not. level maybe you can explain?

best regards
0
 
LVL 6

Expert Comment

by:kmead6
ID: 34952214
I believe it's because you have the margin applied to "#container .initialbox" instead of just ".initialbox". But applying padding to the parent box, like jagadishdulal did would be the better option anyway.
0
 
LVL 1

Author Comment

by:derrida
ID: 34952395
hi its not the selector. i have tried all this. i will go with the outter div padding
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question