Search code examples
htmlcssyui-pure-css

How to stop the text under Images of Pure Grid Div from getting Squashed


I'm using the CSS pure grid class to make a grid of images and placing a text label below each one. However, this is not working out because the text is getting squashed (see the image below):

enter image description here

Here is my code:

  <div class="pure-g" style="margin-top:90px; margin-left:200px">

      <div class="pure-u-lg-1-4 pure-u-md-1-2 pure-u-sm-1" style="margin-right:50px">
          <a href="#" class="thumbnail">
            <img src="sample_image.jpg" width=200px>
            <center>
              <span class="caption" style="color:black" > <br> My Text Under Image</span>
          </center>
        <br>
      </div>

Solution

  • Are you including the necessary CSS file for pure responsive grids?

    In your code, there was a missing ending for the a and div tags. Everything works after closing those tags:

    <link href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" rel="stylesheet"/>
    <link href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css" rel="stylesheet"/>
    
    <div class="pure-g" style="margin-top:90px; margin-left:200px">
      <div class="pure-u-lg-1-4 pure-u-md-1-2 pure-u-sm-1" style="margin-right:50px">
        <a href="#" class="thumbnail">
                <img src="sample_image.jpg" width=200px>
                <center>
                  <span class="caption" style="color:black" > <br> My Text Under Image</span>
              </center>
            <br>
            </a>
      </div>
    </div>