html - 如何阻止我的背景图像相互重叠

标签 html css background

我希望背景图像并排显示(大小相等),它们之间没有空格。我的代码执行了此操作,但图像相互重叠了一点,因此无法跨越 100% 的容器。

我将 background-size 设置为 25% 100%;,但是图像重叠了一点,我不希望它们重叠。我希望它们大小相同并并排显示,它们之间没有间距。

    .education {
        background: linear-gradient(rgba(141, 153, 174, 0.8), rgba(141, 153, 174, 0.5)),
        url(https://picsum.photos/200/300?random1)  no-repeat fixed, url(https://picsum.photos/200/300?random2) no-repeat fixed, url(https://picsum.photos/200/300?random3) no-repeat fixed, url(https://picsum.photos/200/300?random4) no-repeat fixed;
        background-size: 25% 100%;
        background-position: 0% 0%, 25% 0%, 50% 0%, 75% 0%;
    }
<section id="education" class="education">
                <div class="content-wrap">
                <h2>Education</h2>https://jsfiddle.net/Temitope/61pz03hy/5/#run
    
                <!-- School details: copy this whole block to add more schools. -->
                <h3>Andela - Lagos, Nigeria</h3>
                <p>Mobile Web Specialist Certificate, 2019</p>
                <p>Five Months Learning Program. </p>
    
                <h3>University Of  Lagos - Akoka, Lagos</h3>
                <p>Bachelor of Science, 2013-2017</p>
                <p>Major in Economics and International Trade.</p>
    
                <h3>Kith and Kin International College - Ikorodu, Lagos</h3>
                <p>West African Exam Council Certificate, 2009-2013</p>
                <p> Major in Commerce.</p>
              </div>
            </section>

我希望背景图像并排显示(大小相等),它们之间没有空格。我还希望图像根据设备宽度自行调整大小。

最佳答案

我必须将背景位置设置为:0% 0%、33.333% 0%、66.667% 0%、100% 0%;。我的水平值是错误的,它们最多只占容器的 75%。

.education {
     background: linear-gradient(rgba(141, 153, 174, 0.8), rgba(141, 153, 174, 0.5)),
     url(https://picsum.photos/200/300?random1)  no-repeat fixed, url(https://picsum.photos/200/300?random2) no-repeat fixed, url(https://picsum.photos/200/300?random3) no-repeat fixed, url(https://picsum.photos/200/300?random4) no-repeat fixed;
     background-size: 25% 100%;
     background-position:  0% 0%, 33.333% 0%, 66.667% 0%, 100% 0%;;
 }
<section id="education" class="education">
            <div class="content-wrap">
            <h2>Education</h2>

            <!-- School details: copy this whole block to add more schools. -->
            <h3>Andela - Lagos, Nigeria</h3>
            <p>Mobile Web Specialist Certificate, 2019</p>
            <p>Five Months Learning Program. </p>

            <h3>University Of  Lagos - Akoka, Lagos</h3>
            <p>Bachelor of Science, 2013-2017</p>
            <p>Major in Economics and International Trade.</p>

            <h3>Kith and Kin International College - Ikorodu, Lagos</h3>
            <p>West African Exam Council Certificate, 2009-2013</p>
            <p> Major in Commerce.</p>
          </div>
        </section>

关于html - 如何阻止我的背景图像相互重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58227893/

相关文章:

html - 我想把这个有问题的图片放到我的网站上,我把 CSS 代码和 HTML 都放进去了,但它仍然不起作用

CSS 下拉菜单总是在旁边(不是底部)

jquery - 如何在灯箱 View Fancybox 中悬停图像时添加描述

html - AngularJS:一个 index.html 中的注册和内容页面

java - 如何创建看起来 TextView 比它大的列表项?

php - onClick 参数中带有字符串

html - 可变宽度的固定侧边栏旁边的流动内容

html - 无法 overflow hidden : hidden; and transform: translate: -100%; 的标题

html - 添加 margin-top 导致页面扩展

iOS 移动设备拉伸(stretch)背景图片