【问题标题】:css multiple images with gradient issue with responsivecss 多张带有渐变问题的图像,响应式
【发布时间】:2021-03-30 22:09:58
【问题描述】:

这是我的预期输出:

这是我生成的输出,宽度为375px

这里是767px:

这是我的css代码:

.content{
        width:100%;
        background-image: 
        url("./../../images/small/tantum-winter-home.jpg"),
        url("./../../images/small/tantum-dotts-house.png"),
        linear-gradient(90deg,#e8e6e6 50%, rgba(0,212,255,0) 20%);
        background-repeat: no-repeat, no-repeat;
        background-position: 65% 20%, right 56% bottom;
        height: 35rem;
    }

我在这里面临两个问题:

  1. 虚线图案并非完全以所有尺寸开头(请参阅 767 像素)
  2. 如何通过向下的某个点来限制渐变。(应停止在虚线图案开始的位置)目前适用于整个高度。

【问题讨论】:

    标签: css css-gradients css-backgrounds


    【解决方案1】:

    这是一个更适合响应式的不同想法:

    .box {
       height:300px;
       box-sizing:border-box;
       /* the padding will control the radial-gradient area */
       padding: 50px 50px 0 calc(100% - 200px);
       background:
        /* the image placed at right:0 and top:50px */
        url(https://picsum.photos/200/150) right 0 top 50px no-repeat,
        /* the main color having width:(100% - 100px) and height:(100% - 50px) */
        linear-gradient(#e8e6e6 0 0) 0 0/calc(100% - 100px) calc(100% - 50px) no-repeat,
        /* the circles pattern (2px radius inside a 8px*8px square) */
        radial-gradient(circle 2px,#757575 97%,transparent) 0 0/8px 8px content-box content-box;
       
    }
    <div class="box"></div>

    您可以用您的 png 替换径向渐变,并具有以下内容:

    .box {
       height:300px;
       box-sizing:border-box;
       /* the padding will control the radial-gradient area */
       padding: 50px 50px 0 calc(100% - 200px);
       background:
        /* the image placed at right:0 and top:50px */
        url(https://picsum.photos/200/150) right 0 top 50px no-repeat,
        /* the main color having width:(100% - 100px) and height:(100% - 50px) */
        linear-gradient(#e8e6e6 0 0) 0 0/calc(100% - 100px) calc(100% - 50px) no-repeat,
        /* the circles pattern */
        url("./../../images/small/tantum-dotts-house.png") content-box content-box;
       
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-11
      • 2015-08-29
      相关资源
      最近更新 更多