Put text under image slider without breaking harm the layout

Asked

Viewed 239 times

1

I own an image slider so: inserir a descrição da imagem aqui

I need to put "subtitles" underneath each of the images. How it is in html:

<div id="pic-0">
    <a href="/ModuloPublico/AssociacaoCooperativa/Index/101">
        <img src="url da imagem" alt="Licor de Maracujá com Mousse" width="302" height="192" widht="100%">
    </a>
    <a href="/ModuloPublico/AssociacaoCooperativa/Index/101">
        <img src="url da imagem" alt="Licor de maracuja concentrado" width="302" height="192" widht="100%">
    </a>

    <a class="previous" href="#pic-3" onclick="bgenScroll();">&lt;</a>
    <a class="next" href="#pic-1" onclick="bgenScroll();">&gt;</a>

</div>

When trying to put caption underneath each image, the slider "breaks" by staying as follows: inserir a descrição da imagem aqui

How did the html:

<div id="pic-0">
    <a href="/ModuloPublico/AssociacaoCooperativa/Index/101">
        <img src="url da imagem" alt="Licor de Maracujá com Mousse" width="302" height="192" widht="100%">
    </a>"Licor de Maracujá com Mousse"
    <a href="/ModuloPublico/AssociacaoCooperativa/Index/101">
        <img src="url da imagem" alt="Licor de maracuja concentrado" width="302" height="192" widht="100%">
    </a>"Licor de maracuja concentrado"

    <a class="previous" href="#pic-3" onclick="bgenScroll();">&lt;</a>
    <a class="next" href="#pic-1" onclick="bgenScroll();">&gt;</a>

</div>

CSS class:

.fieldset {
        border: 1px solid #ccc;
        padding: 25px;
    }

    .legend {
        width: inherit; /* Or auto */
        padding: 0 10px; /* To give a bit of padding on the left and right */
        border-bottom: none;
    }

    .gallerywrapper {
        margin-top: 5000px;
        width: 100%;
        height: 270px;
        margin: 0 auto;
        position: relative;
        font-family: verdana, arial, sans-serif;
    }

        .gallerywrapper .gallery {
            position: absolute;
            text-decoration: none;
            margin-top: 50%;
            left: 0;
            top: 0;
            height: 270px;
            width: 100%;
            overflow: hidden;
            text-align: center;
        }

            .gallerywrapper .gallery div {
                width: 100%;
                height: 900px;
                padding-top: 10px;
                position: relative;
            }

                .gallerywrapper .gallery div img {
                    clear: both;
                    display: inline-block;
                    margin: 0 auto;
                    border: 0;
                }

                .gallerywrapper .gallery div h3 {
                    padding: 10px 0 0 0;
                    margin: 0;
                    font-size: 18px;
                }

                .gallerywrapper .gallery div p {
                    padding: 5px 0;
                    margin: 0;
                    font-size: 12px;
                    line-height: 18px;
                }


    .gallery .previous {
        display: inline;
        float: left;
        margin-left: 10px;
        margin-top: 80px;
        text-decoration: none;
    }

    .gallery .next {
        display: inline;
        float: right;
        margin-right: 10px;
        margin-top: 80px;
        text-decoration: none;
    }

Some way to leave the caption of each image, under each image?

  • Have you tested putting the text together with the image inside the <a></a> tag? With the code you posted there is not to simulate the error shown in the image, then it is difficult to help you...

  • @hugocsl yes, it looks the same, but the text is linked

  • Text can’t have a link or whatever?

  • @hugocsl whatever, just need each caption to be under each photo without harming the layout

1 answer

2


Here is a simple option that can help you. The concept is to write the "legend" in the global attribute title of link, and then using a pseudo-element ::after you will show on the screen what is written inside that title. It looks complicated but it’s not rss

Your tag <a> has to have an attribute title="" and the class="slide"

<a class="slide" href="#" title="Licor de Maracujá com Mousse">

Now with this CSS a.slide::after {content: attr(title);} I’ll get what’s written on title of <a> and place below the image.

#pic-0 a.slide::after {
  content: attr(title);
  ...
}

See the final result with your code as it would look.

#pic-0 a.slide {
position: relative;
text-align: center;
}
#pic-0 a.slide::after {
content: attr(title);
position: absolute;
display: inline-block;
bottom: -20px;
left: 0;
}

.fieldset {
  border: 1px solid #ccc;
  padding: 25px;
}

.legend {
  width: inherit;
  /* Or auto */
  padding: 0 10px;
  /* To give a bit of padding on the left and right */
  border-bottom: none;
}

.gallerywrapper {
  margin-top: 5000px;
  width: 100%;
  height: 270px;
  margin: 0 auto;
  position: relative;
  font-family: verdana, arial, sans-serif;
}

.gallerywrapper .gallery {
  position: absolute;
  text-decoration: none;
  margin-top: 50%;
  left: 0;
  top: 0;
  height: 270px;
  width: 100%;
  overflow: hidden;
  text-align: center;
}

.gallerywrapper .gallery div {
  width: 100%;
  height: 900px;
  padding-top: 10px;
  position: relative;
}

.gallerywrapper .gallery div img {
  clear: both;
  display: inline-block;
  margin: 0 auto;
  border: 0;
}

.gallerywrapper .gallery div h3 {
  padding: 10px 0 0 0;
  margin: 0;
  font-size: 18px;
}

.gallerywrapper .gallery div p {
  padding: 5px 0;
  margin: 0;
  font-size: 12px;
  line-height: 18px;
}


.gallery .previous {
  display: inline;
  float: left;
  margin-left: 10px;
  margin-top: 80px;
  text-decoration: none;
}

.gallery .next {
  display: inline;
  float: right;
  margin-right: 10px;
  margin-top: 80px;
  text-decoration: none;
}
<div id="pic-0">
  <a class="slide" href="/ModuloPublico/AssociacaoCooperativa/Index/101" title="Licor de Maracujá com Mousse">
    <img src="https://placecage.com/100/100" alt="Licor de Maracujá com Mousse" width="302" height="192" widht="100%">
  </a>
  <a class="slide" href="/ModuloPublico/AssociacaoCooperativa/Index/101" title="Licor de Maracujá com Mousse">
    <img src="https://placecage.com/100/100" alt="Licor de maracuja concentrado" width="302" height="192" widht="100%">
  </a>

  <a class="previous" href="#pic-3" onclick="bgenScroll();">&lt;</a>
  <a class="next" href="#pic-1" onclick="bgenScroll();">&gt;</a>

</div>

  • almost gave, but the other image went down instead of staying on the side of the first as print: https://imgur.com/a/NT47N8Z

  • @Standalone edited the answer, I changed the CSS to adjust as needed, one look now copies the first two classes I put there #pic-0 a.slide and #pic-0 a.slide ::after that I also put some more properties, so http://prntscr.com/nuezv9

  • 1

    boaa valeu vc is the guy kkkkkkkk a lengenda was on top of the photo I only changed the bottom: -120px; and it worked very much thank you.

  • @Cool standalone that worked out ai! abs

Browser other questions tagged

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