How to write inside an image border

Asked

Viewed 48 times

0

Hello I would like to write inside the border but I could not follow my code

.first-row-sites .img-responsive, .form-sites-container, .second-row-sites .img-responsive {
    border-top: 50px solid #006400;
	  border-radius: 1px;
	   }
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="second-row-sites">


<a title="Clique para acessar" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/495197/0st9yhngses-benjamin-child.jpg"> <img class="img-responsive" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/495197/0st9yhngses-benjamin-child.jpg" alt="Carta de Serviços da Saúde" /> </a>
</div>

</div>
</div>
</div>

  • Do you really want to write something there, or do you want to do or menu, or put a link or button whatever? Or just put any text?

  • put some text

  • Put the element you want for example <p> in position Absolute and move it with left and top to adjust.

1 answer

0


If that’s what you really want... You can create a pseudo element in your link, where the image is inside and in this pseudo element you write the text you want. In fact it will be on the link, but will give the impression that is inside the edge of the image.

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

.first-row-sites .img-responsive,
.form-sites-container,
.second-row-sites .img-responsive {
    border-top: 50px solid #006400;
    border-radius: 1px;
}
a {
  display: inline-block;
  width: 100%;
  position: relative;
}
a::after {
  content: 'meu texto aqui';
  position: absolute;
  top: 5px;
  left:5px;
  z-index: 1;
  font-size: 30px;
  color: #fff;
}
<div class="container">
    <div class="row">
        <div class="col-sm-4">
            <div class="second-row-sites">
                <a title="Clique para acessar" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/495197/0st9yhngses-benjamin-child.jpg"> 
                  <img class="img-responsive" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/495197/0st9yhngses-benjamin-child.jpg" alt="Carta de Serviços da Saúde" /> 
                </a>
            </div>
        </div>
    </div>
</div>

  • It did not work because use wordpress and when I put the css it replicates on all pages, would have to be specific for this div if it goes to all pages.

  • @Ludi then puts an ID on that link fipo <a id="texto" href="..."><img></a> and in CSS put the property in #texto { css } This will make the CSS apply only to the element that has the id="texto". My reply is an example to help you, if you had made it clear in the reply that it is for just an image on a wordpress page etc, I could have already included these details in the reply not in the comment here, but I hope it helps with this tip

  • I couldn’t, but.

  • @Ludi if you ask a question with an environment closer to the real you have there maybe I can help... but if you want CSS only works for one particular element, or it has to have a class that only it has, or it has to have an id ai vc puts the CSS selector to a #ID and not to a . Class

Browser other questions tagged

You are not signed in. Login or sign up in order to post.