【问题标题】:repeat an image from a specfic position to another specific position将图像从特定位置重复到另一个特定位置
【发布时间】:2010-07-31 20:52:26
【问题描述】:

我想在 div 的背景中设置一个图像,其属性可以从 div 的开头重复该图像到 div 的 99% 的高度。

这可能吗?或者我必须找到另一轮工作?

【问题讨论】:

    标签: html css image


    【解决方案1】:

    并非纯粹使用 CSS 背景重复。一旦您指定了一个方向(x 或 y)的重复,您将获得该元素 100% 的宽度或高度;

    您可以尝试添加一个覆盖 <div>s 高度 1% 的元素,从而隐藏背景图像。

    另一种选择是嵌套 2 个 div,并将背景图像添加到嵌套元素:

    <div style="height: 100%">
        <div style="height: 99%; background: url(img.png) repeat-y 0 0;">
    </div>
    

    【讨论】:

      【解决方案2】:

      你不能只用 CSS 来做到这一点,你需要一个 HTML &lt;div&gt; 或类似的来定位背景。

      【讨论】:

        【解决方案3】:

        尝试使用这个 css:

        .myimg {
            background-image:url(path here) repeat left top;
            height:99%;
        }
        

        您需要将myimg 类应用于图像。你可能想在那里调整高度。

        请注意,您还可以通过指定左侧和顶部的值来自定义图像的开始/重复位置,例如:

        background-image:url(path here) repeat 20% 50%;
        

        【讨论】:

          猜你喜欢
          • 2011-09-28
          • 2016-06-07
          • 1970-01-01
          • 1970-01-01
          • 2015-07-29
          • 1970-01-01
          • 2019-10-19
          • 1970-01-01
          • 2018-03-17
          相关资源
          最近更新 更多