user3447573
user3447573

Reputation: 23

how to center the content inside a div using css

I made a website that is working fine on large devices ,on mobile device I am trying to center the icon below the slider using this code below in the class icn

.icn{
margin:0 auto;
}

but it is not centered. The website I made is in www.devmakk.com/tution

Upvotes: 1

Views: 82

Answers (4)

Djave
Djave

Reputation: 9329

Centered content will also need a width applied to it if it is display:block.

.icn{
    margin:0 auto;
    width:20px;
    display:block; // this is needed.
}

Otherwise, the parent container will just need to have text-align:center; on it.

Upvotes: 2

Dev_FullStack
Dev_FullStack

Reputation: 33

you can try this:

.icn{
margin-Left:auto;
margin-Right:auto;
}

Upvotes: 0

stranger4js
stranger4js

Reputation: 267

you have to change the display of the icon to block for example

.icn{
display:block
margin:0 auto;
}

Don't forget display:block otherwise it won't work

Upvotes: 0

Akshay
Akshay

Reputation: 14348

You can use text-align:center If you provide your relevant code in a fiddle i woul have been able to test it

Upvotes: 0

Related Questions