html - 如何在减小屏幕宽度的同时防止覆盖图像上的文本

标签 html css

“我正在减小屏幕宽度,但段落文本覆盖了图像,我应该做些什么来防止覆盖文本”

“这是部分网站 build ,我尝试在代码中使用一些 css3 属性,但无法解决问题”

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <style>
        #facilities{
            height: 430px;
            background: #fff;
        }
        #facilities .facility-img {
            width: 40%;
            float: left;
        }
        #facilities .facility-img img{
            width: 600px;
            border-radius: 50%;
            padding: 30px 70px;
        }
        #facilities .facility-info{
            float: right;
            width: 50%;
            text-align: center;
            padding-top: 60px;
        }
        #facilities .facility-info h1{
            color: #333;
        }
        #facilities .facility-info  p{
            color: #333;
        }
    </style>
</head>
<body>
    <section id="facilities">
        <div class="container">
            <div class="facility-img ">
                <img src="https://images.pexels.com/photos/1170979/pexels-photo-1170979.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="facility-photo">
            </div>
            <div class="facility-info">
                <h1>In a hospital , half of the patients get better food than at home.</h1>
                <p>~Gerhard KocSher</p>
                <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit.Sit autem ducimus delectus nam aut neque vitae, ab repellendus, qui, quibusdam eum commodi sunt? Non veniam quos illo, assumenda doloremque sit possimus sunt architecto quo neque doloribus provident consequuntur eius error.
                </p>
            </div>
        </div>
    </section>    
</body>
</html>

最佳答案

将图像上的 width: 600px 更改为 width: 100%

关于html - 如何在减小屏幕宽度的同时防止覆盖图像上的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58624058/

相关文章:

html - 我怎样才能删除这个按钮?CSS

javascript - 在 Jquery 中按下后更改切换状态图标

php - <div> 标签中的背景图像未显示

php - 在附加的 HTML 上使用 jQuery 效果

css - CSS给出错误: “Expected selector for the style rule”

css - 如何使 div bg 图像适合全屏并允许滚动下面的内容

java - 使用 jQuery/Ajax 将多个选定的复选框发送到 Java

html - Bootstrap 4 制作相同的按钮

css - 使用内联样式以不同于列表项的方式为列表元素符号着色

css - IE 中的 Flex 元素超出父级的宽度