如何使边框向上移动

huangapple go评论100阅读模式
英文:

How to make border to move upwards

问题

要求.container边框向上移动一点,而不带着其他(body)边框。

英文:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

body {
  outline: 3px solid blue;
  height: 100vh;
  outline-offset: 5px;
}

.container {
  border: 2px solid red;
  height: 610px;
  width: 350px;
  transform: translateY(30px);
}

<!-- language: lang-html -->

&lt;body&gt;
  &lt;div class=&quot;container&quot;&gt;&lt;/div&gt;
&lt;/body&gt;

<!-- end snippet -->

I want .container border to move upwards abit without carrying the other (body)border along

答案1

得分: 0

不太清楚...
我理解的是:

  • 红色边框向上移动?

你需要删除 transform: translateY(30px);

如果你仍然想在顶部留一些空间供文本使用,可以添加 padding-top

body {
  outline: 3px solid blue;
  height: 100vh;
  outline-offset: 5px;
}

.container {
  border: 2px solid red;
  height: 610px;
  width: 350px;
  padding-top: 30px;
}
<div class="container">
  <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet aspernatur assumenda consequatur cupiditate debitis eveniet expedita, facilis ipsa magnam maiores minima nam, necessitatibus nemo officia officiis quasi sapiente temporibus voluptas?</div>
  <div>A ab aliquam at dolore dolorum eaque earum eum impedit incidunt iure iusto laborum magni modi nesciunt nobis, placeat provident quaerat saepe veniam voluptate! Animi at consequuntur obcaecati recusandae sunt?</div>
</div>
英文:

Not very clear...
What I'm understanding is:

  • border red move upward?

you need to delete the transform: translateY(30px);

if you still want some space on top for the text, you add padding-top

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

body {
  outline: 3px solid blue;
  height: 100vh;
  outline-offset: 5px;
}

.container {
  border: 2px solid red;
  height: 610px;
  width: 350px;
  padding-top: 30px;
}

<!-- language: lang-html -->

&lt;div class=&quot;container&quot;&gt;
  &lt;div&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet aspernatur assumenda consequatur cupiditate debitis eveniet expedita, facilis ipsa magnam maiores minima nam, necessitatibus nemo officia officiis quasi sapiente temporibus voluptas?&lt;/div&gt;
  &lt;div&gt;A ab aliquam at dolore dolorum eaque earum eum impedit incidunt iure iusto laborum magni modi nesciunt nobis, placeat provident quaerat saepe veniam voluptate! Animi at consequuntur obcaecati recusandae sunt?&lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月6日 19:12:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76628207.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定