move figcaption under the image for mobile devices

123 views Asked by At

i'm in the process of making an old site responsive and i've encountered a few hurdles.

I would like the desktop version to show the fig captions on the right side, but in the mobile version the fig captions should be under the figure. Unfortunately, I can't get the figcaptions to appear under the image.

I am thankful for every help!

Best wishes

    <style type="text/css">
        body {
            margin: 60px;
        }
        .sidebar {
            margin: 0;

            padding: 0;
            text-align: left;
            width: 100%;
            background-color: transparent;
            position: fixed;
            height: 100%;
            overflow: auto;
           
            list-style-type: none;
            font-size: 14px !important;
        }

        .sidebar a {
            display: block;
            color: #666666;
            padding: 8px;
            text-decoration: none;
            list-style-type: none;
        }

        .sidebar li {
            list-style: none;
            text-decoration: none;
        }


        .sidebar a.active {
            background-color: transparent;
            color: #4d4d4d;
            list-style-type: none;
        }

        .sidebar a:hover:not(.active) {
            background-color: transparent;
            color: rgb(49, 49, 49);
        }
        .figure {
    
            margin: 0;
        }
        .figure img {
            vertical-align:;
        }
        .figure figcaption {
          
            margin-left: 10px;
        }
        @media screen and (min-width: 768px) {.d-xl-none{display: none; }}

        
        @media screen and (max-width: 768px) {
            body {margin: 20px;}
            div.content {margin-left: 0;}
            div.preview {margin-left: 0;}
            .sidebar {height: 100%;position: relative;text-align: center;margin-bottom: 0px !important;display: none; }
            .sidebar a {float: left;align-items: center; }
            .caption {text-align: center !important; }
            .containerCarousel {margin-top: 0px;margin-bottom: 150px;width: 1fr;} }
            #LP_img{align-content: center; margin: 0 auto;}

            .overlay {height: 100%;width: 0;position: fixed;z-index: 1;top: 0;left: 0;background-color: rgb(0, 0, 0);background-color: rgba(0, 0, 0, 0.9);overflow-x: hidden;transition: 0.5s;}
            .overlay-content {position: relative;top: 10%;width: 100%;text-align: center;margin-top: 30px;}
            .overlay a {padding: 8px;text-decoration: none;font-size: 15px;color: #818181;display: block;transition: 0.3s;}
            .overlay a:hover,
            .overlay a:focus {color: #f1f1f1;}
            .overlay .closebtn {position: absolute;top: 20px; right: 45px; font-size: 40px;}

        @media screen and (max-height: 480px) {
            .overlay a {font-size: 20px }
            .overlay .closebtn {font-size: 20px;top: 15px; right: 35px;}
            .sidebar a {text-align: center;float: none;}
            .sidebar {display: none; }
            .content { margin-top: 10px !important;}
            .preview { margin-top: 10px !important; }
            .caption {text-align: center !important; }
            .imagePreview {margin: auto 0;}
        }

        .imagePreview{

          max-width: 400px;

        }
       
    </style>
<!doctype html>
<html lang="en">

<head>
    <title>Christoph Urwalek</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


</head>


<body>
    <!-- START Mobile Nav-->
    <div class="continer">
    
    <div id="myNav" class="overlay">
        <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
        <div class="overlay-content">
            <a href="./painting.html">painting</a>
            <a href="./hungabunga.html">drawing</a>
            <a href="#">collage</a>
            <a href="#">video</a>
            <a href="#">current</a>
            <a href="#">text</a>
            <a href="#">biography</a>
            <a href="#">contact</a>
        </div>
    </div>
    <span class="d-xl-none" style="font-size:30px;cursor:pointer; color: #4d4d4d;" onclick="openNav()">&#9776; <font size="-1"><b>Christoph Urwalek</b></font></span>
  </div>
    <!-- END Mobile Nav-->
    <!--START Wrapper-->
    <div class="container-fluid my-container align-items-center">
        <!--START Sidebar -->
        <div class="row my-row">
            <div class="col-md-3 ">
                <nav class="sidebar-header sidebar">
                    <li><a class="active" href="./hungabunga.html"><b>Christoph Urwalek</b></a></li>
                    <li><a href="./painting.html">painting</a></li>
                    <li><a href="./drawing.html">drawing</a></li>
                    <li><a href="#">collage</a></li>
                    <li><a href="#">video</a></li>
                    <li><a> </a></li>
                    <li><a href="#">current</a></li>
                    <li><a href="#">text</a></li>
                    <li><a href="#">biography</a></li>
                    <li><a href="#">contact</a></li>
                </nav>
            </div>
            <!--END Sidebar -->
            
            <div class="col-md-9 ">

                    <table class="table table-borderless ">
                      <tbody>
                        <!---->
                        <tr>
                          <td><figure class="figure d-flex justify-content-center">
                            <img src="http://christophurwalek.at/index/Wandcollage.jpg" class="figure-img img-fluid rounded imagePreview" alt="A generic square placeholder image with rounded corners in a figure.">
                            <figcaption class="figure-caption"><a href="###">Test first line<br>Test second line</figcaption>
                          </figure></td>
                        </tr>
                       <!---->
                       
                       <!---->
                       
                        <tr>
                          <div class="container">
                          <td><figure class="figure d-flex justify-content-center">
                            <img src="./assets/img/thumbnails/Fake_35x47cm_2020__.jpg" class="figure-img img-fluid rounded imagePreview" alt="A generic square placeholder image with rounded corners in a figure.">
                            <figcaption class="figure-caption caption center-block">real_FAKE<br>2020</figcaption>
                           
                          </figure>
                        </div></td>
                        </tr>
                         <!---->
                         <tr>
                          <td><figure class="figure d-flex justify-content-center">
                            <img src="./assets/img/thumbnails/Various_2020_wand.jpg" class="figure-img img-fluid rounded imagePreview" alt="A generic square placeholder image with rounded corners in a figure.">
                            <figcaption class="figure-caption">Various III</figcaption>
                            <figcaption class="figure-caption">2020</figcaption>
                          </figure></td>
                        </tr>
                        

                        


                      </tbody>
                    </table>



                         

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

<div class="container">

    
    <!--END Wrapper-->
    <script type="">
        function openNav() {
          document.getElementById("myNav").style.width = "100%";
        }
        
        function closeNav() {
          document.getElementById("myNav").style.width = "0%";
        }
        </script>


    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
    </script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
    </script>
</body>

</html>

sorry for adding all the code.. I don't know what could have been of importance to you.

1

There are 1 answers

2
Alex Angelico On

The solution is to change d-flex to block for smaller devices. (I wouldn't do that, I think you should change everything to use Bootstrap 4 as it's intended, and remove the table which makes no sense).

@media screen and (max-width: 768px) {
       /* all the styles you want */
       .d-flex {
           display: block !important;
        }
  }

Keep in mind there are errors in the code, there is an empty vertical-align for .figure img, and there is an unclosed <a> element.