Advertisement
nuggetin

html

Jun 21st, 2022
1,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.38 KB | None | 0 0
  1. <html>
  2.  
  3. <style>
  4.     * {
  5.         box-sizing: border-box;
  6.     }
  7.  
  8.     .row::after {
  9.         content: "";
  10.         clear: both;
  11.         display: table;
  12.     }
  13.  
  14.     [class*="col-"] {
  15.         float: left;
  16.         padding: 15px;
  17.     }
  18.  
  19.     @media only screen and (min-width: 768px) {
  20.  
  21.         /* For desktop: */
  22.         .col-1 {
  23.             width: 8.33%;
  24.         }
  25.  
  26.         .col-2 {
  27.             width: 16.66%;
  28.         }
  29.  
  30.         .col-3 {
  31.             width: 25%;
  32.         }
  33.  
  34.         .col-4 {
  35.             width: 33.33%;
  36.         }
  37.  
  38.         .col-5 {
  39.             width: 41.66%;
  40.         }
  41.  
  42.         .col-6 {
  43.             width: 50%;
  44.         }
  45.  
  46.         .col-7 {
  47.             width: 58.33%;
  48.         }
  49.  
  50.         .col-8 {
  51.             width: 66.66%;
  52.         }
  53.  
  54.         .col-9 {
  55.             width: 75%;
  56.         }
  57.  
  58.         .col-10 {
  59.             width: 83.33%;
  60.         }
  61.  
  62.         .col-11 {
  63.             width: 91.66%;
  64.         }
  65.  
  66.         .col-12 {
  67.             width: 100%;
  68.         }
  69.     }
  70.  
  71.     /* ///////////////////////// */
  72.     #picContainer {
  73.         border: 1px solid black;
  74.         height: 350px;
  75.         width: 100%;
  76.         padding: 15px;
  77.     }
  78.  
  79.     .optContainer {
  80.         border: 1px solid black;
  81.         width: 135px;
  82.         height: 135px;
  83.         margin: 0 auto;
  84.         padding: 5px;
  85.     }
  86.  
  87.     .prev {
  88.         width: 100%;
  89.         max-width: 250px;
  90.         height: auto;
  91.         display: block;
  92.         margin-left: auto;
  93.         margin-right: auto;
  94.     }
  95.  
  96.     .imgSelected {
  97.         width: 120px;
  98.         display: block;
  99.         margin-left: auto;
  100.         margin-right: auto;
  101.     }
  102.  
  103.     .hoveredImg {
  104.         border: 1px solid #ff0000;
  105.     }
  106. </style>
  107.  
  108.  
  109. <script>
  110.     var imgCount = 0;
  111.     var imgContent = [
  112.         ["imgOption1", "BOM", "Lorem ipsum dolor sit amet."],
  113.         ["imgOption2", "DOM", "Nullam fringilla imperdiet eleifend"],
  114.         ["imgOption3", "JavaScript", "Cras dapibus ipsum a consequat tincidunt"]
  115.     ];
  116.  
  117.     function initialize() {
  118.         document.getElementById("imgViewer").src = "bom.png"
  119.         document.getElementById("topicTtl").innerHTML = imgContent[0][1]
  120.         document.getElementById("topicDescrpt").innerHTML = imgContent[0][2]
  121.     }
  122.  
  123.     function previewImg(imgSrc) {
  124.         document.getElementById("imgViewer").src = imgSrc.src;
  125.  
  126.         for (let i = 0; i < imgContent.length; i++) {
  127.            if (imgSrc.id == imgContent[i][0]) {
  128.                imgCount = i
  129.            }
  130.        }
  131.  
  132.        document.getElementById("topicTtl").innerHTML = imgContent[imgCount][1]
  133.        document.getElementById("topicDescrpt").innerHTML = imgContent[imgCount][2]
  134.    }
  135. </script>
  136.  
  137. <head>
  138.     <title>Image Viewer DOM </title>
  139. </head>
  140.  
  141. <body onload="initialize()">
  142.     <!-- image view container -->
  143.     <div class="row">
  144.         <div class="col-3">
  145.             <!-- blank -->
  146.         </div>
  147.         <div class="col-6">
  148.             <div id="picContainer">
  149.                 <div class="row">
  150.                     <div class="col-8">
  151.                         <img id="imgViewer" class="prev" src="">
  152.                     </div>
  153.                     <div class="col-4">
  154.                         <!-- title and description -->
  155.                         <h3 id="topicTtl">Title</h3>
  156.                         <p id="topicDescrpt">Description</p>
  157.                     </div>
  158.                 </div>
  159.             </div>
  160.         </div>
  161.         <div class="col-3">
  162.             <!-- blank -->
  163.         </div>
  164.     </div>
  165.     <!-- hover or clicked to display -->
  166.     <div class="row">
  167.         <div class="col-3">
  168.             <!--blank-->
  169.         </div>
  170.         <div class="col-2">
  171.             <div class="optContainer">
  172.                 <img id="imgOption1" alt="no image" src="bom.png" class="imgSelected" onmouseover="previewImg(this)">
  173.             </div>
  174.         </div>
  175.         <div class="col-2">
  176.             <div class="optContainer">
  177.                 <img id="imgOption2" alt="no image" src="dom.png" class="imgSelected" onmouseover="previewImg(this)">
  178.             </div>
  179.         </div>
  180.         <div class="col-2">
  181.             <div class="optContainer">
  182.                 <img id="imgOption3" alt="no image" src="intro.png" class="imgSelected" onmouseover="previewImg(this)">
  183.             </div>
  184.         </div>
  185.         <div class="col-3">
  186.             <!--blank-->
  187.         </div>
  188.     </div>
  189. </body>
  190.  
  191. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement