【问题标题】:How to fill right side of screen CSS?如何填充屏幕CSS的右侧?
【发布时间】:2023-02-25 06:46:31
【问题描述】:

我正在制作一个网页,目前,我的背景是这样的:

<body id="bg" style="padding: 2%; background: linear-gradient(#e66465, #9198e5); height: 100%; background-repeat: repeat-y; background-size: 50% auto;">
</body>

它填满了屏幕的左侧,对吧? 但我需要它来填充右侧。

有谁知道如何做到这一点?

【问题讨论】:

  • 删除background-size: 50% auto;

标签: css


【解决方案1】:

您可以使用 CSS 属性 background-position 来做到这一点:

body {
  padding: 2%; 
  background: linear-gradient(#e66465, #9198e5); 
  height: 100%; 
  background-repeat: repeat-y;
  background-size: 50% auto;
  background-position: right;
  
}
<body id="bg">
</body>

【讨论】:

    【解决方案2】:

    将 background-position: right; 添加到您的 CSS。

    <body id="bg" style="padding: 2%; background: linear-gradient(#e66465, #9198e5); height: 100%; background-repeat: repeat-y; background-size: 50% auto; background-position: right;">
    </body>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 2022-11-18
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 2017-04-03
      相关资源
      最近更新 更多