【发布时间】:2021-10-11 14:18:31
【问题描述】:
我对使用 HTML 和 CSS 非常陌生。在我主要通过复制/粘贴代码设计的网站中,当鼠标悬停在它们上方时,我有一堆带有文本的图像。这包括很多我认为可能会干扰我的分子式中的下标的 CSS,但我不确定为什么或在哪里? subscript in lower line 我的第一个问题是子标签导致下标被放在下一行并被其他字母覆盖。我通过添加来修复:
<style>
.textwithblurredbg sub{
vertical-align: baseline;
font-size: 60%;
position: relative;
left:-4 em;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
但是,现在我的分子式的数字和字母之间有很大的空格。任何解决此问题的解决方案将不胜感激(请保持语言尽可能简单)。先感谢您!! subscript numbers not attached to previous text
这是我的可能有干扰的 CSS 代码:
<style>
.textwithblurredbg{
width:300px;
height:200;
display: inline-block;
margin:8px;
position:relative;
}
.textwithblurredbg img{
width: 100%;
height: 100%;
border-radius:10px;
transition:.3s;
}
.textwithblurredbg:hover img{
filter:blur(2px) brightness(60%);
box-shadow:0 0 16px #A0C1D5;
}
.textwithblurredbg :not(img){
position:absolute;
top:10%;
z-index:1;
color: #fff;
font-family:Arial;
text-align:left;
line-height:25px;
margin:10px;
width:95%;
opacity:0;
transition;.3s;
letter-spacing:default;
}
.textwithblurredbg h3{
top:2.5%;
font-family:Arial;
text-align:center;
}
.textwithblurredbg:hover :not(img){
opacity:1;
}
以及我如何使用子标签:
<div class="textwithblurredbg">
<img src="https://groups.chem.ubc.ca/chem_stockroom/images/Acetic Acid 2.0M.jpg">
<h3>Acetic Acid Solution 2.0M</h3>
<h5>Molecular Formula: C<sub>2</sub>H<sub>4</sub>O<sub>2</sub> or CH3COOH<br><br>Formula Weight: 60.05 g/mol<br>Appearance: Colourless, clear liquid<br><br>Safety: Can cause burns/blisters if comes into contact with skin.
【问题讨论】:
标签: html css spacing subscript