user11263277
user11263277

Reputation:

center span class element over image

Trying to get span element to display in the center of my image to create an interactive button. Span class is "plus_own" element displays in left corner of the image.

.plus_own {
   font-size: 70px;
   color: white;
   font-family: unc;
   position: relative;
   font-weight: bold;
   top: -30px;
   transition: all 0.4s ease;
}

Centered span class element trying to create an interactive button.

Upvotes: 0

Views: 27

Answers (1)

mullac
mullac

Reputation: 683

I would recommend taking a look at this to get a better understanding of how this works.

How I would recommend to do it is something like this:

.container {
  position: relative;
  text-align: center;
  color: white;
}

.plus_own {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: red;
  font-weight: bold;
}
<div class="container">
    <img src="https://cdn.shopify.com/s/files/1/1330/4567/files/DSC_0838_1024x1024.jpg?v=1522089465" style="width:100%;">
    <span class="plus_own">Some Text</span>
</div>

Upvotes: 2

Related Questions