Achy97
Achy97

Reputation: 1024

Create center alignment text using HTML CSS

I have a picture of a view of text inside a div which is a center alignment. The views of texts are shown as -

View1

another example

View 2

But if I use the following code -

margin-left: auto;
margin-right: auto;
text-align: center;

but this code gives me

enter image description here

Here is the code in jsfiddle-

https://jsfiddle.net/2bu0gym3/

How to get the desired alignment view, thanks in advance!

Upvotes: 0

Views: 67

Answers (3)

sadegh
sadegh

Reputation: 1642

in @media you forgot add .testimonials p

@media only screen and (max-width:767px){
  .testimonials img,.work-service,.testimonials p{
    margin-left:auto;
    margin-right: auto;
    text-align: center !important; 
  }

Upvotes: 0

Bárbara Tribino
Bárbara Tribino

Reputation: 31

You simply add:

p {
text-align: center
}

It should work. As far as I can tell, there's nothing (no class, id or something else) in your code right now that should make the text be center aligned.

Upvotes: 1

m1k1o
m1k1o

Reputation: 2364

You have to center p itself or its parent.

.testimonials p ,.events P{
  margin: 0% 3%;
  text-align:center;
}

Upvotes: 1

Related Questions