html - 如何将此项目转换为代码?
问题描述
这是我的 css 和 html 代码:
我的目标是创建一个我在图像中指定的框
.stone-item{
width: 330px;
transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
position: relative;
margin: 0;
}
.stone-item img{
width: 330px;
height: 220px;
}
.stone-item .stone-content{
transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
position: absolute;
bottom: -50%;
left: 0;
background: aqua;
}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="css.css">
</head>
<body>
<div class="stone-item">
<a href="#"><img src="" alt=""></a>
<div class="stone-content">
<h4> </h4>
</div>
</div>
</body>
</html>
问题出在哪里?为什么不起作用????
我想要的输出:
after : 鼠标悬停后
解决方案
这是你的代码。
HTML
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="css.css">
</head>
<body>
<div class="stone-item">
<a href="#"><img src="https://i.stack.imgur.com/SjIvg.png" alt=""></a>
<div class="stone-content">
<h4>adsfasdf</h4>
<p>
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
</p>
</div>
</div>
</body>
</html>
CSS
.stone-item {
width: 330px;
transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
position: relative;
margin: 0;
overflow: hidden;
}
.stone-item img {
width: 330px;
height: 220px;
}
.stone-item .stone-content {
transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
position: absolute;
bottom: calc(110px - 100%);
left: 0;
background: rgba(0, 255, 255, 0.6);
width: 100%;
padding: 20px;
box-sizing: border-box;
}
.stone-item .stone-content h4 {
margin: 0;
}
.stone-item:hover .stone-content {
bottom: 0;
}
推荐阅读
- windows - 我如何解决 wine 中的桌面窗口管理器问题
- c++ - 在这种情况下,我可以将模板类的构造函数保持为私有吗?
- python - 构建 Plotly Dash 时出错(npm run build)
- python - 如何根据我从数值函数创建的新数据集的某个值找到我的数据集的数量
- django - 我在 /listings/5689-resot-relly-market 收到此错误 AttributeError,'Profile' 对象没有属性'favourite',请提供任何帮助
- kotlin - 如何将图像分享到 Whatsapp 并支持 Android 10 以上和以下版本
- django - 用列表代替模型填充 forms.MultipleChoiceField
- javascript - 如何在另一个 ejs 模板上显示保存在变量中的一串 ejs 代码?
- prometheus - 如何从 /tsdb-status url 计算当前 prometheus TSDB 存储大小
- flutter - 在颤动中的按钮内使用函数的行为不符合预期