【发布时间】:2022-12-03 22:31:36
【问题描述】:
这将如何完成? https://jsfiddle.net/mLwcyj9u/
你能帮助我吗?
我试图将播放图像放在蓝绿色正方形的中间。
这就是我想要做的。
将游戏图像放在蓝绿色方块内。
这些都是细节。
这就是一切。
我在下面提供了一个 sn-p。
.channel-tile {
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-radius: 4px;
width: 180px;
float: left;
display: block;
margin-bottom: 18px;
background: #2E2E2E;
position: relative;
}
.channel-tile__image-area {
width: 180px;
height: 0;
padding-top: 100%;
position: relative;
z-index: 0;
border-radius: 4px;
background: red;
border: 1px solid blue;
}
.channel-tile__artwork {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
width: 170px;
height: 170px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
z-index: 0;
background: teal;
}
.cover {
-webkit-appearance: none;
appearance: none;
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 72px;
height: 72px;
border-radius: 50%;
cursor: pointer;
border: 9px solid blue;
background: transparent;
filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.7));
}
.cover::before {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 27px solid blue;
transform: translateX(4px);
}
<div class="channel-tile">
<div class="channel-tile__image-area">
<span class="channel-tile__artwork"></span>
</div>
</div>
<div class="cover">
</div>
【问题讨论】:
-
很简单,将你的
.cover元素放在-area中,并在 CSS 中使用绝对位置(等),就像你对__artwork所做的那样。 -
我不明白,播放图像总是乱七八糟。
-
然后看下面的答案。我刚刚将
<div class="cover"移动到-area并添加了与__artwork相同的“绝对居中样式”
标签: css css-position