html - 文字与图片重叠

标签 html css

我是 html 和 css 的新手。我写了如下代码。我面临的问题是:一旦浏览器尺寸减小,文本就会与图像重叠。图像的尺寸没有改变。

html代码是:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet"  href="style.css">
    <title>Favorite app</title>
</head>
<body>
    <h1 class="title">MY FAVORITE APP</h1>
    <div class="app">
        <div class="screenshot"><img src="Images/app.png" alt="This is a screenshot"></div>
        <div class="description">Ham hock porchetta mollit corned beef
sed spare ribs aliqua nulla. Mollit ut
tongue qui adipisicing officia sirloin.
Turkey boudin tri-tip minim consequat
pastrami pariatur laborum fugiat nisi
beef ribs in dolore kielbasa sunt. Id cillum
aliquip turkey, ball tip cupidatat pastrami.
Meatloaf in fatback, pariatur ut nulla
reprehenderit jerky t-bone sirloin incidi-</div>
    </div>
</body> 
</html>

CSS代码是:

.screenshot{
    max-width: 460px;
    padding-left: 10px;
}
.description{
    max-width: 705px;
    margin: 30px;
    font-size: 30px;
    color:#7C8B88;
    width:700px;
}
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
} 
.app{
    display: flex;
}
.title{
    margin: 30px 10px;
    padding: 70px;
    padding-left: 10px;
    width: 1095px;
    height: 100px;
    border:20px;
    font-size: 50px;
    font-family:sans-serif;
    background-color: #33BEBE;
    color: white;
    box-sizing: border-box;
}

最佳答案

让您的图片具有响应性,您所缺少的一切

.screenshot img{
    width:100%;
}

jsBin demo

P.S:不要为你的 H1 title 添加宽度,否则你会在一瞬间失去响应能力(参见演示)

关于html - 文字与图片重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30039140/

相关文章:

CSS 背景属性 - 速记与长格式

html - 内部 div 元素位置

javascript - 固定定位点击后自行重置

javascript - 使用 MySQL 填充 jQuery DataTable

html - 跨浏览器设置输入 "size"-属性

javascript - 悬停图像放大并在其上显示文本 CSS3

python - 如何在 Django 中添加对评论的回复?

javascript - 如何在 jQuery 中使用多个选择器

html - 仅当值为空时如何设置样式选择下拉列表

jquery - 如何将类添加到幻灯片中的当前图像?