Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to center text in the middle of an image with CSS

1 Answer

0 votes
/* style-test.css */

.row {
  position: relative;
  display: inline-block;
}

.row h3 {
  position: absolute;
  margin: 0;
  color: #FFF;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
<!-- test.html -->

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="css/style-test.css">
</head>

<body>

    <div class="row">
        <div id="image">
            <h3>image</h3>
            <img src="img/no_picture_avatar.jpg" alt="image" style="width:200px;height:100px;">
        </div>
    </div>

</body>
</html>

 



answered Jun 28, 2017 by avibootz

Related questions

1 answer 231 views
1 answer 234 views
1 answer 216 views
1 answer 200 views
2 answers 269 views
2 answers 238 views
...