Skip to content Skip to sidebar Skip to footer

Top Margin Of An Element (css)

I need to set a margin to the top of an element. The text must be within the element and have a top margin of N pixels. Here is what I want to achieve: Fiddle: http://jsfiddle.net

Solution 1:

DEMO or you may be try with padding-top instead margin-top as follows

.name {
    display:block;
    color: #000;
    padding-top: 50px;
}

Solution 2:

Since .breadcrumbs has position: relative, set position: absolute; to .name.

Solution 3:

You need to add display: inline-block; to get the margin to work.

For instance,

.name {
    color: #000;
    margin-top: 50px;
    display: inline-block;
}

Hope this helps.

Solution 4:

in this case, you must specify the parent ELEMENT position relative and absolute position subsidiary and specify top: 0;

Solution 5:

the <span> is an inline element. That means you cant apply margin or padding to it.

For the solution to your problem you have -at least- two options.

1.Change the container of your text to a block element, like <div>

so:

<spanclass="name">Name</span>

will become

<divclass="name">Name</div>

2.Change the behavior of your span by making it a block or inline-block element with this css:

.name {
display:inline-block
/* rest of your css */

These two articles will give you a good idea of what is inline and block

http://www.impressivewebs.com/difference-block-inline-css/

http://css-tricks.com/almanac/properties/d/display/

Post a Comment for "Top Margin Of An Element (css)"