+ 1

How i can bring this text to center of div.

Css:- .first { position:relative; top:45%; left:45%; height:100px; width:100px; background:linear-gradient(to right,white,grey); box-shadow:4px 4px 8px 8px darkgrey; } a { padding:45px; text-decoration:none; font-family:sans-serif; font-size:20px; color:grey; top:45px; } Html:- <div class="first"><a href="">hulk</a></div>

1st Sep 2019, 1:30 PM
Avinash
Avinash - avatar
2 Antworten
+ 2
make sure you apply styling to div.first . only .first doesn't work. also use line-height:100px; for vertical alignment. div.first{ text-align:center; /*horizontal */ vertical-align:center; /*vertical*/ line-height:100px; } //Thanks to Gordon sir for correction https://www.sololearn.com/learn/CSS/1090/?ref=app https://www.sololearn.com/learn/CSS/1091/?ref=app
1st Sep 2019, 1:40 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
0
In your .first css, add text-align:center;
1st Sep 2019, 1:39 PM
Chetali Shah
Chetali Shah - avatar