English quotes how to edit?

Asked

Viewed 424 times

3

I’m making a website that I found that a text will have English quote, so far it’s okay to just do the code, but the problem starts when I edit your font to get bigger, the final quote creates an automatic height that I couldn’t even put in fixed height, use position Absolute does not resolve pq the quote has to stay at the end and at the beginning of the sentence, so how do I make the end quote correctly at the end of the text?

IMAGE

APAS INGLESAS

CSS CODE

.noticias .interna H5 {
    width: 100%;
    display: flex;
    font: normal bold 23px/33px 'Libre Baskerville', sans-serif;
    text-align: center;
    justify-content: center;
    color: #333333;
    padding: 0 0 30px 0;
}
.noticias .interna H5:BEFORE {
    content: "“";
    font: normal bold 50px/33px 'Libre Baskerville', sans-serif;
}
.noticias .interna H5:AFTER {
    content: "”";
    font: normal bold 50px/33px 'Libre Baskerville', sans-serif;
}
  • Put your html with the div etc, it is better to give you an accurate answer

  • I’ve done it before posting and the result is the same the final quote goes up

  • Have you thought of a solution via Javascript?

  • Not because I didn’t think it would be necessary, but I guess I’ll have to find a way to do with!!

  • Dude I posted an answer where I could adjust using top same. But if that’s not what you need tell me I’ll edit there if I have to.

  • 1

    It would be something like this using JS: https://jsfiddle.net/6fk1xdv7/

  • You can even put the first quotes by JS tb, to be next to the first word of the text.

  • I was going to put image but this solution there is better vlw I think I’ll stay with her even

  • I’ll remove the answer for now, when I think of something I’ll give you an idea

  • Dude I made a simple adjustment in CSS and I think now it’s the way you wanted, in case you don’t want to use the JS option now you have an option only with CSS. [] s

Show 5 more comments

2 answers

2

EDIT

I made this new answer because I believe that the previous one was not the best option, both semantically and the features that CSS offers that should be used in the correct way and not with "way" to work.

First see that HTML has the tag <q> ... </q> where Q means quote See what the Mozilla documentation says about this tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q

The HTML element <q> indicates that the attached text is a short quotation in line. Most modern browsers implement this by enclosing the text in quotes.

Then see that CSS has the attribute quote where it is possible to customize the type of quotation mark that you want to use. https://developer.mozilla.org/en-US/docs/Web/CSS/quotes

The CSS property quote indicates how user agents should render quotes.

Ex:

q {
  quotes: '“' '”';
}

Now see when the tag <q> is rendered by the browser it includes two pseudo-elements ::before and ::after automatically.

inserir a descrição da imagem aqui

Now the answer I believe is most appropriate

First don’t put the ::before and ::after on the tag <h5>, in that case use the tag <q> within the title tag: <h5><q>...

Now just set the type of quote that you want (quotation marks), and then stylize the ::before and ::after tag <q>

See how the result of custom quotes and default quotes placed directly inside the text. OBS: I left the comments in the code

div {
    width: 400px;
    margin: 0 auto;
}
h5 {
    font-family: 'Libre Baskerville', sans-serif;
    font-size: 32px;
    text-align:center;
}
q::before, q::after {
    quotes: '“' '”' ; /* estilo das aspas */
    color: red; /* cor das aspas */
    font-size: 40px; /* tamanho da fonte das aspas */
    position: relative;
    top: 4px; /* altura das aspas relativas ao texto, ajuste ótico devido a variação do tamanho da fonte das aspas*/
}
<div>
    <h5><q>sit amet consectetur</q></h5>
    <h5><q>Lorem ipsum dolor sit amet consectetur adipisicing elit. Expedita, consequatur.</q></h5>
    <h5>Lorem ipsum dolor "sit amet consectetur" adipisicing elit.</h5>
</div>


A CSS-only option

Look I don’t know if there’s any other CSS influencing your code, but here’s a normal setting in top and bottom with position:absolut NOTE: I separated the shorthand of font to better visualize the attributes.

In the top: you control the time you want just like in bottom and uses margin and padding to give the spacing between the quotation marks and the text.

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}
.interna {
    width: 40%;
    margin: 0 auto;
}
.noticias .interna H5{ 
    width:100%; 
    line-height: 33px;
    font-weight: normal;
    font-size: 23px;
    font-family: 'Libre Baskerville', sans-serif;
    text-align:center; 
    color:#333333; 
    padding-bottom: 0;
    position: relative;
}    
.noticias .interna H5::before{ 
    content: "“";
    line-height: 33px;
    font-weight: normal;
    font-size: 50px;
    font-family: 'Libre Baskerville', sans-serif;
    position: absolute;
    top: 0.5rem;
    margin-left: -1.5rem;
}
.noticias .interna H5::after{ 
    content: "”";
    line-height: 33px;
    font-weight: normal;
    font-size: 50px;
    font-family: 'Libre Baskerville', sans-serif;
    position: absolute;
    bottom: -0.5rem;
    padding-left: 10px;
}
<div class="noticias">
    <div class="interna">
        <h5>Lorem ipsum dolor psa!</h5>
    </div>
</div>
<div class="noticias">
    <div class="interna">
        <h5>Lorem ipsum dolor sitanimi eveniet laborum ipsa a!</h5>
    </div>
</div>
<div class="noticias">
    <div class="interna">
        <h5>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur hic ullam fugiat! Veniam accusamus voluptates animi eveniet laborum ipsa a!</h5>
    </div>
</div>

  • The problem is that the content on H5 can not have any width, because I do not know when text it will put, the line break will be done by the client giving a enter that in the site editor will be a br, then using position Absolute does not fit and even if it had width would not be able to put the quote at the end of the text with position abosolute

  • @user4451 the size I put in just to visualize better, it is not determinant in my answer, my question now is if you want the last quote to be at the end of the last word is this, like below along with the last line?

  • I want you to stay at the end of the text after the last word not in the corner leaving a space

  • @user4451 so just take a padding-bottom default that every H element has and put instead of top in the after a negative bottom to adjust. I’ve already edited the answer look how it turned out

  • it’s no use he’s in the corner with a white space I think the output for this is going to be a create an image of two quotes and put as image, then I think it’s right, I come back here to see if it worked

2


A solution using Javascript to insert quotes at the end of the text. How you are using flex, insert a direct tag into the text would make it positioned to the right of the text. So I suggest you include all the text in a tag span to insert another content in stylised quotes.

With a for you insert the final quotation marks at the end of all texts in <h5><span>:

var h5 = document.querySelectorAll("h5 span");
for(var x=0; x<h5.length; x++){
   h5[x].innerHTML += "<span>”</span>";
}
.noticias .interna H5{
   width:100%;
   display:flex;
   position: relative;
   font:normal bold 23px/33px 'Libre Baskerville', sans-serif;
   text-align:center;
   justify-content:center;
   color:#333333;
   /* padding:0 0 30px 0; removido */
}
.noticias .interna H5:BEFORE{
   content:"“";
   font:normal bold 50px/33px 'Libre Baskerville', sans-serif;
}
/* código abaixo adicionado para pegar o span da aspas */
.noticias .interna h5 span span{
   position: relative;
   font:normal bold 50px/0 'Libre Baskerville', sans-serif;
   top: 15px;
}
<div class="noticias">
   <div class="interna">
      <h5>
         <span>
            O Brasil tem posição de destaque em relação ao etanol.
            <br>
            Temos a solução aqui em casa, importar
            <br>
            baterias não vai alimentar a economia local.
         </span>
       </h5>
   </div>
</div>

  • No use putting a span pq the text is centered at each line has a br at the end, so if you put position Absolute will not stand next to the text automatically and always in the corner understood? The quotation mark has to follow the text in the normal way only with the larger size

  • I understood, but BEFORE also makes the first quotes always in the corner before the sentence. You want the final quotation mark to be right after the last word?

  • If it was to be in the bottom corner I had already solved, tendeu?

  • Updated response! =]

  • vlw ai for help, I’ve already marked as solved, pity that we could not solve with css, so far I do not understand why the quotes create this height alone when increase your source, but the important thing is that we have found a way

  • A CSS-only option came out nicely ;)

Show 1 more comment

Browser other questions tagged

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