GVKun编程网logo

是否有将元素推到一边的 CSS 属性边距除外?

1

关于是否有将元素推到一边的CSS属性边距除外?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于)预期css(css-rparentexpected)"用于@media查询中的第4级css语

关于是否有将元素推到一边的 CSS 属性边距除外?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法、 不起作用、Angular:

    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css等相关知识的信息别忘了在本站进行查找喔。

    本文目录一览:

    是否有将元素推到一边的 CSS 属性边距除外?

    是否有将元素推到一边的 CSS 属性边距除外?

    如何解决是否有将元素推到一边的 CSS 属性边距除外?

    对于我的 200x200px 容器,我添加了 10% 的右边距,我相信在我的 html 中它下面的内容会被推到右边距区域之外,但是在我的代码中,内容没有被推开(下面) 来自我的容器,即使我在容器的四周放置了边距。

    即使我有容器边距,为什么元素仍然与我的容器重叠?我只能通过在我的 html 中执行多个 br 来解决这个问题吗?或者是否有实际的 CSS 方法来解决这个问题?

    我真的很感激这方面的帮助,非常感谢!

    1. body {
    2. color: black;
    3. background-color: rgb(240,240,240);
    4. margin: 1%;
    5. }
    6. .container {
    7. width: 200px;
    8. height: 200px;
    9. outline: red solid 5px;
    10. Box-sizing: border-Box;
    11. position: absolute;
    12. top: 165%;
    13. margin: 10%;
    14. background-image: url(ezio.jpg);
    15. }
    16. .textBox1 {
    17. width: 40%;
    18. left: 2%;
    19. Box-sizing: border-Box;
    20. outline: red solid 5px;
    21. background-color: cyan;
    22. padding: 20px;
    23. border: 10px;
    24. border-style: dotted;
    25. position: relative;
    26. }
    27. .textBox2 {
    28. width: 40%;
    29. Box-sizing: border-Box;
    30. outline: red solid 5px;
    31. position: absolute;
    32. left: 45%;
    33. top: 18%;
    34. background-color: darkkhaki;
    35. }
    36. .textBox3 {
    37. width: 40%;
    38. Box-sizing: border-Box;
    39. outline: red solid 5px;
    40. Box-sizing: border-Box;
    41. position: relative;
    42. left: 10%;
    43. }
    44. .textBox4 {
    45. width: 40%;
    46. Box-sizing: border-Box;
    47. outline: red solid 5px;
    48. Box-sizing: border-Box;
    49. position: absolute;
    50. left: 55%;
    51. top: 70%;
    52. }
    1. <div class="container"></div>
    2. <div class="textBox1">
    3. <p> ding Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,numquam quod SAEpe excepturi eaque debitis repellat,quibusdam ratione atque,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
    4. </div>
    5. <br>
    6. <div class="textBox2">
    7. kingen simp Lorem ipsum dolor sit amet consectetur,adipisicing elit. Aliquid eum excepturi veritatis officia iusto cum reprehenderit corrupti accusamus,accusantium sequi nobis ab nesciunt quibusdam natus tenetur at enim ipsum magni?</div>
    8. <br>
    9. <div class="textBox3">
    10. <h4>amazin</h4>
    11. <p>pie Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
    12. </div>
    13. <br>
    14. <div class="textBox4">
    15. <h6>water</h6>
    16. <p> indigo sill Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
    17. </div>
    18. <div class="categories">
    19. <h5>
    20. categories
    21. </h2>
    22. <ul>
    23. <li><a href="#">juice</a></li>
    24. <li><a href="#">grapes</a></li>
    25. <li><a href="#">mango</a></li>
    26. <li><a href="test.html">fish</a></li>
    27. </ul>
    28. </div>
    29. <table>
    30. <thead>
    31. <tr>
    32. <th>name</th>
    33. <th>age</th>
    34. <th>email</th>
    35. </tr>
    36. </thead>
    37. <tbody>
    38. <tr>
    39. <td>kano minto</td>
    40. <td>56</td>
    41. <td>minto@gmail.com</td>
    42. </tr>
    43. <tr>
    44. <td>heni smio</td>
    45. <td>24</td>
    46. <td>dkeo@gmail.com</td>
    47. </tr>
    48. <tr>
    49. <td>elise trum</td>
    50. <td>35</td>
    51. <td>trm@gmail.com</td>
    52. </tr>
    53. </tbody>
    54. </table>
    55. <br>

解决方法

在 position relative 中,元素相对于自身定位。但是,绝对定位的元素是相对于其父元素的。具有 position: absolute 的元素从正常文档流中删除。它会自动定位到其父元素的起点(左上角)。

除了 texbox1 之外,所有元素都处于绝对位置,因此摆脱了文档通常会如何流动它们。一个接一个。

假设我们从 textbox1 中取出相对位置。 textbox1 应该位于绿色框的顶部,但由于流程中断,它被认为是通常的事物方案中的第一个元素。
下面的例子。

  1. body {
  2. color: black;
  3. background-color: rgb(240,240,240);
  4. margin: 10%;
  5. }
  6. .container{
  7. width: 200px;
  8. height: 200px;
  9. outline: green solid 5px;
  10. box-sizing: border-box;
  11. position: absolute;
  12. top: 16%;
  13. margin: 10%;
  14. background-image: url(ezio.jpg);
  15. }
  16. .textbox1 {
  17. width: 40%;
  18. box-sizing: border-box;
  19. outline: red solid 5px;
  20. background-color: cyan;
  21. padding: 20px;
  22. border: 10px;
  23. border-style: dotted;
  24. }
  25. .textbox2 {
  26. width: 40%;
  27. box-sizing: border-box;
  28. outline: red solid 5px;
  29. position: absolute;
  30. left: 45%;
  31. top: 18%;
  32. background-color: darkkhaki;
  33. }
  34. .textbox3 {
  35. width: 40%;
  36. box-sizing: border-box;
  37. outline: red solid 5px;
  38. box-sizing: border-box;
  39. position: relative;
  40. left: 10%;
  41. }
  42. .textbox4 {
  43. width: 40%;
  44. box-sizing: border-box;
  45. outline: red solid 5px;
  46. box-sizing: border-box;
  47. position: absolute;
  48. left: 55%;
  49. top: 70%;
  50. }
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  6. <title>GamerHub</title>
  7. <link rel="stylesheet" href="C:/Users/zeren/CSS/newcssgamerhub.css" type="text/css">
  8. </head>
  9. <body>
  10. <div class="container"></div>
  11. <div class="textbox1">
  12. <p> ding Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,numquam quod saepe excepturi eaque debitis repellat,quibusdam ratione atque,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
  13. </div>
  14. <br>
  15. <div class="textbox2">
  16. kingen simp Lorem ipsum dolor sit amet consectetur,adipisicing elit. Aliquid eum excepturi veritatis officia iusto cum reprehenderit corrupti accusamus,accusantium sequi nobis ab nesciunt quibusdam natus tenetur at enim ipsum magni?</div>
  17. <br>
  18. <div class="textbox3">
  19. <h4>amazin</h4>
  20. <p>pie Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
  21. </div>
  22. <br>
  23. <div class="textbox4">
  24. <h6>water</h6>
  25. <p> indigo sill Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae aliquid ea,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
  26. </div>
  27. <div class="categories">
  28. <h5>
  29. categories
  30. </h2>
  31. <ul>
  32. <li><a href="#">juice</a></li>
  33. <li><a href="#">grapes</a></li>
  34. <li><a href="#">mango</a></li>
  35. <li><a href="test.html">fish</a></li>
  36. </ul>
  37. </div>
  38. <table>
  39. <thead>
  40. <tr>
  41. <th>name</th>
  42. <th>age</th>
  43. <th>email</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. <tr>
  48. <td>kano minto</td>
  49. <td>56</td>
  50. <td>minto@gmail.com</td>
  51. </tr>
  52. <tr>
  53. <td>heni smio</td>
  54. <td>24</td>
  55. <td>dkeo@gmail.com</td>
  56. </tr>
  57. <tr>
  58. <td>elise trum</td>
  59. <td>35</td>
  60. <td>trm@gmail.com</td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. <br>
  65. </body>

当我们重新应用相对于 textbox1 的位置时,它会根据代码中的堆叠位置流动。容器后。 下面的例子;

  1. body {
  2. color: black;
  3. background-color: rgb(240,240);
  4. margin: 10%;
  5. }
  6. .container{
  7. width: 200px;
  8. height: 200px;
  9. outline: green solid 5px;
  10. box-sizing: border-box;
  11. position: absolute;
  12. top: 16%;
  13. margin: 10%;
  14. background-image: url(ezio.jpg);
  15. }
  16. .textbox1 {
  17. width: 40%;
  18. position: relative;
  19. box-sizing: border-box;
  20. outline: red solid 5px;
  21. background-color: cyan;
  22. padding: 20px;
  23. border: 10px;
  24. border-style: dotted;
  25. }
  26. .textbox2 {
  27. width: 40%;
  28. box-sizing: border-box;
  29. outline: red solid 5px;
  30. position: absolute;
  31. left: 45%;
  32. top: 18%;
  33. background-color: darkkhaki;
  34. }
  35. .textbox3 {
  36. width: 40%;
  37. box-sizing: border-box;
  38. outline: red solid 5px;
  39. box-sizing: border-box;
  40. position: relative;
  41. left: 10%;
  42. }
  43. .textbox4 {
  44. width: 40%;
  45. box-sizing: border-box;
  46. outline: red solid 5px;
  47. box-sizing: border-box;
  48. position: absolute;
  49. left: 55%;
  50. top: 70%;
  51. }
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
  6. </div>
  7. <div class="categories">
  8. <h5>
  9. categories
  10. </h2>
  11. <ul>
  12. <li><a href="#">juice</a></li>
  13. <li><a href="#">grapes</a></li>
  14. <li><a href="#">mango</a></li>
  15. <li><a href="test.html">fish</a></li>
  16. </ul>
  17. </div>
  18. <table>
  19. <thead>
  20. <tr>
  21. <th>name</th>
  22. <th>age</th>
  23. <th>email</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <tr>
  28. <td>kano minto</td>
  29. <td>56</td>
  30. <td>minto@gmail.com</td>
  31. </tr>
  32. <tr>
  33. <td>heni smio</td>
  34. <td>24</td>
  35. <td>dkeo@gmail.com</td>
  36. </tr>
  37. <tr>
  38. <td>elise trum</td>
  39. <td>35</td>
  40. <td>trm@gmail.com</td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. <br>
  45. </body>

同样,如果要去掉容器的相对绝对位置,然后保持所有内容完好无损,那么 textbox1 将从容器休息的最后一个边界开始,将打破流程并根据它们自己放置它们。

  1. body {
  2. color: black;
  3. background-color: rgb(240,240);
  4. margin: 10%;
  5. }
  6. .container{
  7. width: 200px;
  8. height: 200px;
  9. outline: green solid 5px;
  10. box-sizing: border-box;
  11. top: 16%;
  12. margin: 10%;
  13. background-image: url(ezio.jpg);
  14. }
  15. .textbox1 {
  16. width: 40%;
  17. position: relative;
  18. box-sizing: border-box;
  19. outline: red solid 5px;
  20. background-color: cyan;
  21. padding: 20px;
  22. border: 10px;
  23. border-style: dotted;
  24. }
  25. .textbox2 {
  26. width: 40%;
  27. box-sizing: border-box;
  28. outline: red solid 5px;
  29. position: absolute;
  30. left: 45%;
  31. top: 18%;
  32. background-color: darkkhaki;
  33. }
  34. .textbox3 {
  35. width: 40%;
  36. box-sizing: border-box;
  37. outline: red solid 5px;
  38. box-sizing: border-box;
  39. position: relative;
  40. left: 10%;
  41. }
  42. .textbox4 {
  43. width: 40%;
  44. box-sizing: border-box;
  45. outline: red solid 5px;
  46. box-sizing: border-box;
  47. position: absolute;
  48. left: 55%;
  49. top: 70%;
  50. }
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,mollitia ipsum repellendus. Nostrum at possimus fugiat dolores excepturi!</p>
  6. </div>
  7. <div class="categories">
  8. <h5>
  9. categories
  10. </h2>
  11. <ul>
  12. <li><a href="#">juice</a></li>
  13. <li><a href="#">grapes</a></li>
  14. <li><a href="#">mango</a></li>
  15. <li><a href="test.html">fish</a></li>
  16. </ul>
  17. </div>
  18. <table>
  19. <thead>
  20. <tr>
  21. <th>name</th>
  22. <th>age</th>
  23. <th>email</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <tr>
  28. <td>kano minto</td>
  29. <td>56</td>
  30. <td>minto@gmail.com</td>
  31. </tr>
  32. <tr>
  33. <td>heni smio</td>
  34. <td>24</td>
  35. <td>dkeo@gmail.com</td>
  36. </tr>
  37. <tr>
  38. <td>elise trum</td>
  39. <td>35</td>
  40. <td>trm@gmail.com</td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. <br>
  45. </body>

所以我猜所有的盒子都按照编程指南的行为方式运行,但需要微调,直到达到预期的结果。

访问此站点,它使用 CSS 定位来实现视觉效果。enter link description here

) 预期 css(css-rparentexpected)

) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法

Visual Studio Code does not support 4 级范围语法呢。此外,MDN 表示目前只有 Firefox 支持该语法。如果您需要跨浏览器支持,您现在需要坚持使用原始的 max-width 语法:

@media (max-width: 768px) {
    h1 {
        font-size: 3em;
        color: mediumvioletred;
    }
    nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: mediumaquamarine;
    }
}

否则,你所拥有的是正确的。

" alt="">

OSC 请你来轰趴啦!1028 苏州源创会,一起寻宝 AI 时代

css 样式   引入  href="css/layout.css?id=7" 是什么意思?

不起作用" alt=" 不起作用">

如何解决<link rel="stylesheet" type="text/css" href="{% static ''css/style.css'' %}"> 不起作用

我在 vs-code 上将 css 链接到 html。 center-aliend 在这里不起作用。有没有人知道哪个部分有问题? 我想设置文本“Hello Static!!”到浏览器的中心。

  1. {% load static %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <Meta charset="UTF-8">
  6. <Meta name="viewport" content="width=device-width,initial-scale=1.0">
  7. <link rel="stylesheet" type="text/css" href="{% static ''css/style.css'' %}">
  8. <title>Static Practice</title>
  9. </head>
  10. <body>
  11. <div>Hello Static!!</div>
  12. </body>
  13. </html>

  1. body {
  2. text-align: center;
  3. }

  1. # Static files (CSS,JavaScript,Images)
  2. # https://docs.djangoproject.com/en/3.1/howto/static-files/
  3. STATIC_URL = ''/static/''
  4. STATICFILES_Dirs = [
  5. BASE_DIR / ''static''
  6. ]

Angular: <ol> 添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

Angular:
    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

如何解决Angular: <ol> 添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

我正在 angular 中创建富文本编辑器,当我执行 document.execCommand(''insertOrderedList'') 时,我得到 <ol> 项,它不受我组件的 css 的影响,只有 styles.css 中的 css(主 css 文件在项目的根目录)影响我使用 document.execCommand 添加的项目。 是否有可能改变这种行为?

解决方法

当然。它的名字是view encapsulation。将其更改为 ViewEncapsulation.none 会产生所需的行为。

  1. @Component({
  2. ...
  3. encapsulation: ViewEncapsulation.none
  4. })

关于是否有将元素推到一边的 CSS 属性边距除外?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法、 不起作用、Angular:

    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css等相关知识的信息别忘了在本站进行查找喔。

    本文标签:

    上一篇如何使用 html 和 less/css 制作完美弯曲的按钮?(css弯曲边框)

    下一篇div 项,弄乱了 CSS 布局(css的div布局)