用于排列图像链接的HTML

时间:2017-09-05 01:15:48

标签: html css

我是一个非常环保的HTML新手,但我已将其与在线代码拼凑在一起。

唯一的问题是这18个图像应排列成3行6(同时保持当前的悬停和链接功能),而不是像目前那样垂直堆叠。有任何想法吗?



.containerS1IR {
  position: relative;
  width: 15%;
}

.imageS1IR {
  opacity: 1;
  display: float;
  left;
  width: 50%;
  height: auto;
  transition: .5s ease;
  backface-visibility: hidden;
  cursor: pointer;
}

.middleS1IR {
  transition: .5s ease;
  opacity: 0;
  position: absolute;
  top: 50%;
  left: 49%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%)
}

.containerS1IR:hover .imageS1IR {
  opacity: 0.5;
}

.containerS1IR:hover .middleS1IR {
  opacity: .80;
}

.textS1IR {
  background-color: maroon;
  color: white;
  font-size: 20px;
  padding: 5px 15px;
}

<h1>
  <font color="#80000" size="+2">
    <marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();">
      The Office of Institutional Research has made the new menu below available for up and coming intuitive web-based reporting. Hover and click the images to navigate.
    </marquee>
  </font>
</h1>

<div class="containerS1IR">
  <img src="https://i.imgur.com/jsn40Sd.png" alt="Enrollment Report Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Overall Enrollment</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/2XkEJjY.png" alt="Freshmen Cohort Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Freshmen Cohort</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/4yA0mlU.png" alt="Student Sub-Populations Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Student Sub-Populations</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/V2666d5.png" alt="Enrollment to Date Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Enrollment to Date</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/alt1B7g.png" alt="Student Success Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Student Success</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/HcC3UCA.png" alt="Academic Costs and Productivity Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Academic Costs and Productivity</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/x9LIrOH.png" alt="Academic Outcomes Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Academic Outcomes</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/084vJ33.png" alt="Finances Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Finances</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/wgyN38M.png" alt="Human Resources Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Human Resources</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/sCN2zbS.png" alt="Infrastructure Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Infrastructure</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/u56c9fv.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/zcZeURw.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/r1LNJZl.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/5BAaZE3.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/BhZlD2g.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/1Cj8Lhu.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/ADhQmDa.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>

<div class="containerS1IR">
  <img src="https://i.imgur.com/96ccSVQ.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
  <div class="middleS1IR">
    <div class="textS1IR">Coming Soon</div>
  </div>
</div>
&#13;
&#13;
&#13;

先谢谢你, 林赛

2 个答案:

答案 0 :(得分:2)

您需要的只是float容器,因此它不占用整个宽度,因为块元素通常会这样做。

.containerS1IR {
position: relative;
width: 15%;
float: left;
}

.imageS1IR {
opacity: 1;
width: 50%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
cursor: pointer;
}

.middleS1IR {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 49%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%)
}

.containerS1IR:hover .imageS1IR {
opacity: 0.5;
}

.containerS1IR:hover .middleS1IR {
opacity: .80;
}

.textS1IR {
background-color: maroon;
color: white;
font-size: 20px;
padding: 5px 15px;
}
<h1><font color="#80000" size="+2">
<marquee behavior="scroll" direction="left" onmouseover="this.stop();" 
onmouseout="this.start();">
The Office of Institutional Research has made the new menu below available 
for up and coming intuitive web-based reporting.  Hover and click the images 
to navigate.
</marquee></font></h1>


<div class="containerS1IR">
<img src="https://i.imgur.com/jsn40Sd.png" alt="Enrollment Report Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Overall Enrollment</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/2XkEJjY.png" alt="Freshmen Cohort Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Freshmen Cohort</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/4yA0mlU.png" alt="Student Sub-Populations Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Student Sub-Populations</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/V2666d5.png" alt="Enrollment to Date Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Enrollment to Date</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/alt1B7g.png" alt="Student Success Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Student Success</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/HcC3UCA.png" alt="Academic Costs and Productivity Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Academic Costs and Productivity</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/x9LIrOH.png" alt="Academic Outcomes Link" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Academic Outcomes</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/084vJ33.png" alt="Finances Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Finances</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/wgyN38M.png" alt="Human Resources Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Human Resources</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/sCN2zbS.png" alt="Infrastructure Link" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Infrastructure</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/u56c9fv.png" alt="Coming Soon" class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/zcZeURw.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/r1LNJZl.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/5BAaZE3.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/BhZlD2g.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/1Cj8Lhu.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/ADhQmDa.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

<div class="containerS1IR">
<img src="https://i.imgur.com/96ccSVQ.png" alt="Coming Soon" 
class="imageS1IR" style="width:100%" onclick="location.href='https://info.schreiner.edu/ICS/University_Resources/Institutional_Research/Census_Report.jnz';">
<div class="middleS1IR">
<div class="textS1IR">Coming Soon</div>
</div>
</div>

或者您可以使用display: inline-block,这将产生相同的效果。

答案 1 :(得分:0)

将样式float:left添加到您的班级.containerS1IR。你的风格应该是这样的:

.containerS1IR {
position: relative;
width: 15%;
float:left;
}

这里Fiddle。 希望它有所帮助