Skip to content Skip to sidebar Skip to footer

Center Text Inside Two Divs Horizontally

How to I can I center this texts horizontally which is inside two divs. When I'm previewing it in Dreamweaver, it is finely centered. My HTML codes:

Solution 1:

v Please try this, it may solve your problem.

There is some CSS changes.

.microcontainers{
    width: 350px;
    height: 600px;
    border:  #9991px solid;
    margin: 40px40px40px40px;
    padding: 15px15px15px15px;
    display: inline-block;
    overflow: hidden;
    text-align: center;
    position: relative;
}

.design{
    font-family: TrajanPro-Regular; 
    font-size:85px;
    color: #999;
    position: absolute;
    left:0;
    right:0;
}

FIDDLE

Solution 2:

Add text-align:center for the paragraph.

.design{
    font-family: TrajanPro-Regular; 
    font-size:85px;
    color: #999;
    text-align:center;
}

Solution 3:

Your content "DESIGN" seem to be overflowing its container thus placing it off-center. Look at this demo where I have added overflow: hidden to .design.

With your updated CSS, including text-align: center for .design you could either reduce the font-size, reduce the padding of .microcontainers or add negative margin on the <p> element

Solution 4:

add

text-align:center; 

in your design class

Solution 5:

Just adding text alignment will fix it see this Fiddle doing exactly what the above user suggested.

.design{
font-family: TrajanPro-Regular; 
font-size:85px;
color: #999;
    text-align: center;
}

but I don't see why you are doing this can you explain it..If you are doing a big project i suggest you use bootstrap

Post a Comment for "Center Text Inside Two Divs Horizontally"