- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道是否有任何方法可以使某个类的每个元素都位于同一位置?我想做的是,当您将鼠标悬停在某个图像上时,我希望有关该图像的文本出现在所有其他图像之间的中央位置。我知道如何通过对每个元素的位置进行硬编码来做到这一点,但这很痛苦,并且不是使用内联样式的好习惯。
所以我的问题是:如何让某个类的每个元素都放在同一个位置?
示例如下:http://homeinspectioncarync.com/testpage/
代码如下:
HTML:
<div class="image-container">
<img src="https://media.licdn.com/mpr/mpr/shrinknp_200_200/p/3/000/00c/2ab/35ae340.jpg" class="images">
<p class="fixed">Dave</p>
<p class="para name">Dave</p>
<p class="para title" ">Senior Inspector</p>
<p class ="para bio " >"This is an example of a Bio. We need to get a bio for each one of our inspectors in order to complete this page! "</p>
</div>
<div class="image-container ">
<img src="http://homeinspectionraleighnc.com/wp-content/uploads/2010/11/Glenns-Photo-1.png " class="images ">
<p class="fixed ">Glenn</p>
<p class="para name " >Glenn </p>
<p class ="para title " >Senior Inspector</p>
<p class ="para bio " >"Licensed: State Home Inspector, General Contractor, Sub-surface Waste Water Inspector. Part owner and senior inspector, responsible for maintaining the highest quality of the field inspections, including both the comprehensiveness
of the inspection itself and the interpersonal relationships with the client, realtor and all other personal involved in the inspection process. "</p>
</div>
<div class="image-container ">
<img src="https://scontent-sjc2-1.xx.fbcdn.net/v/t1.0-1/p160x160/18718_2753855091076_8128390731521222770_n.jpg?oh=d1d49aea28d3cb6ff76033db1ae056ba&oe=57D998E2 " class="images "> <p class="fixed ">Spencer</p>
<p class="para name " >Spencer</p>
<p class ="para title " >Trainee</p>
<p class ="para bio " >" "</p>
</div>
<div class="image-container ">
<img src="https://scontent-sjc2-1.xx.fbcdn.net/v/t1.0-1/c22.22.272.272/s160x160/166620_1817593049535_5878435_n.jpg?oh=78d8a42398b126fc1f75d1b32295029a&oe=57D73E8C " class="images "> <p class="fixed ">Chuck</p>
<p class="para name ">Chuck </p>
<p class ="para title " >Senior Inspector</p>
<p class ="para bio ">" "</p>
</div>
<div class="image-container ">
<img src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/trevor-e1464897672300.jpg " class="images ">
<p class="fixed ">Trevor</p>
<p class="para name ">Trevor </p>
<p class ="para title " >Senior Inspector</p>
<p class ="para bio " >" "</p>
</div>
<div class="image-container ">
<img src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/betterrob-e1464897851528.jpg " class="images "> <p class="fixed ">Rob</p>
<p class="para name ">Rob </p>
<p class ="para title " >Senior Inspector</p>
<p class ="para bio " >" "</p>
</div>
<div class="image-container ">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/d/d0/Chrome_Logo.svg/1024px-Chrome_Logo.svg.png " class="images ">
<p class="fixed ">Anthony</p>
<p class="para name " >Anthony</p>
<p class ="para title " >Senior Inspector</p>
<p class ="para bio " >" "</p>
</div>
CSS:
.images {
height: 100px;
width: 100px;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
transition: all 1000ms ease;
}
.image-container {
position: relative;
margin-left: 80px;
display: inline-block;
}
.image-container:hover .images {
opacity: 0.5;
-webkit-transform: translateY(-10px);
-ms-transform: translateY(-10px);
transform: translateY(-10px);
}
.para {
position: absolute;
display: inline-block;
font-size: 200%;
opacity: 0;
transition: all 1000ms ease;
}
.image-container:hover .para {
opacity: 1;
}
.para.name {
position: absolute;
font-size: 200%;
font-weight: bold;
color: #01ba7c;
}
.para.title {
position: absolute;
font-size: 170%;
font-style: italic;
color: grey;
}
.para.bio {
position: absolute;
font-size: 150%;
width: 450px;
height: 300px;
color: #000000;
}
.fixed {
position: absolute;
top: -30px;
left: 20px;
font-size: 150%;
color: #000000;
}
我希望 .para.name 全部出现在图像第一行下方的中央。 .para.title 和 .para.bio 也应该在中间,但在 .para.name 的左边。
提前感谢您对此的任何帮助!
最佳答案
一种方法是使用 JavaScript getElementsByClassName
,循环访问返回的集合并为每个元素设置相同的位置。
类似于 this .
注意:我已经在您使用的类上设置了 position: fixed;
,在这种情况下可能不是您想做的,但是如果您四处修修补补,您会得到您需要的。
关于html - 一个类的所有元素可以放在同一个位置吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37662675/
我当前项目中的许多类都有几个只能从类本身内部调用的属性和方法。此外,根据类(class)的当前状态,它们可能会扰乱类(class)的工作。 目前,所有这些接口(interface)都在 .h 文件的主
我想使用ngbTabSet将nav-pills in card-header 和tab-content in card-body。但我不知道该怎么做。 这是我尝试实现的示例(使用 bootstrap.
我正在浏览文档以查找如何允许放置在停靠栏图标上。据我所知,建议您使用 LSItemContentTypes,因为 CFBundleTypeOSTypes 已弃用。但是,我无法让 LSItemConte
我正在尝试在书签中使用 jquery UI 作为 slider 。并且 jquery ui 要求在普通 jquery 文件之后包含该文件。 所以到目前为止我所尝试的只是将脚本附加到 header ,同
您好,我尝试了广泛的谷歌搜索,但似乎没有任何帮助。 这是我的场景: 公司 Logo 存储在外部域/网址(矩形)中。 带有谷歌地图的 Ionic 应用程序,将这些 Logo 作为标记放置在 map 上。
我今天在阅读我的一些 C# 代码时发现了这一行: if (ProgenyList.ItemContainerGenerator.Status != System.Windows.Controls.Pr
我刚遇到this question在 Go FAQ 中,它让我想起了困扰我一段时间的事情。不幸的是,我真的不明白答案是什么。 似乎几乎所有非 C 类语言都将类型放在变量名之后,如下所示: var :
这是有效的 HTML 吗? 最佳答案 作为元素可以包含 phrasing content ,以及属于该组,则有效。 从语义上(并且具有一些常识),如果唯一的内容是 , 不;如果它同时包含文本和图像
这是有效的 HTML 吗? 最佳答案 作为元素可以包含 phrasing content ,以及属于该组,则有效。 从语义上(并且具有一些常识),如果唯一的内容是 , 不;如果它同时包含文本和图像
我有两本 T.Parr 写的关于 ANTLR 的书,我到处都看到美元符号和符号的引用。它也对我有用: term : IDENT -> { new TokenNode($IDENT) }; 或更复杂的东
我在实现段控制时遇到了一些问题。因为我希望它是一个固定的标题,所以当我滚动时我总是可以看到它,我已经在 - (UIView *)tableView:(UITableView *)tableView v
我有一个 20x36px (10x18pt) 的箭头图像,当我选择一个 UIImageView 时,将它拖到我的 View Controller 上然后设置图像,它总是模糊的。我只在我的项目中包含 @
How can I put background image when I hover a link Insert Bg in this a when hov
我需要在我的 .container 中添加(最新的第一个)新分区,但在 .controls (按钮)之后。可能吗? 注意:添加新的分区来保存按钮下方的前置控件对我来说不是一个选择。 HTML 需要保持
我是一名优秀的程序员,十分优秀!