首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >只使用负边距而不使用位置起圈?

问只使用负边距而不使用位置起圈?
EN

Stack Overflow用户
提问于 2020-06-01 22:37:26
回答 2查看 77关注 0票数 0

怎样才能只使用负差来提升圆圈呢?我不想用位置。

代码语言:javascript
复制
.task6 {
  margin-top: 5px;
  border: 1px solid red;
}

.task6_row {
  margin: 20px 0;
  width: 100%;
  background-color: lightgray;
  padding: 10px 0;
  border: 1px solid green;
}

.feature_item {
  width: 32%;
  background-color: white;
  padding: 0;
  margin: 5px;
  border-bottom: 1px solid blue;
  text-align: center;
  position: relative;
}

.feature_number {
  width: 50px;
  height: 50px;
  line-height: 50px;
  display: inline-block;
  /* position: absolute; */
  border-radius: 50%;
  background-color: blue;
  color: white;
  text-align: center;
  margin-top: -12px;
  font-family: Arial, Tahoma;
}

.feature_name {}

.feature_desc {
  color: lightgray;
}

.example {
  display: inline-block;
  margin: 10px 0;
  padding: 10px;
  background-color: blue;
  color: white;
  border-radius: 8px;
}
代码语言:javascript
复制
<div class="task6">
  <div class="task6_row">
    <div class="feature_item">
      <div class="feature_number">1</div>
      <h2 class="feature_name">
        cheap price
      </h2>
      <p class="feature_desc">
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Placeat, ratione?
      </p>
      <a class="example" href="">see example</a>
    </div>
  </div>
</div>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-06-01 23:33:12

作为替代,变换()还将使用负值移动元素。将边距顶部属性替换为下面的属性,在Y轴和X轴值中声明您希望它转换的金额。示例:

代码语言:javascript
复制
transform: translate(0, -50%);
票数 1
EN

Stack Overflow用户

发布于 2020-06-01 23:24:02

圆圈的位置依赖于它的容器,容器的裕度为5 5px。如果你重置容器的边缘顶部,你也会移动圆圈。

添加:

代码语言:javascript
复制
   .feature_item { margin:5px; margin-top:0px; }
   .feature_number { margin-top: -12px; }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62142055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档