图像在手机上显示不完全

karen99 2019-08-13 12:39:19
最近心血来潮,想学习Html和CSS。 想在网页上显示一个横幅题头图像,然后在图像下方放上菜单,比如 “关于我们” “ 新闻”之类的,写了两行代码,竟然也工作了,可是在手机上看图像却只显示了一半。我心里想着做一个responsive 的网页的,在什么平台都可以看到网页内容。想着这里高手多,能不能帮我看一下我的代码,希望只是一两句的指点,不会耽误您太多时间

先谢谢大家了

我的css 文件

.bg-img {
/* The image used */
background-image: url("logo.png");

min-height: 160px;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;

/* Needed to position the navbar */
position: relative;
}

/* Position the navbar container inside the image */
.container {
position: absolute;
top:150px;
margin: 20px;
width: 1000px;
}

/* The navbar */
.topnav {
overflow: hidden;
background-color: blue;
}

/* Navbar links */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

.topnav a:hover {
background-color: #ddd;
color: black;
}

我的html文件

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="mystyle.css"></a>
</head>
<body>

<div class="bg-img">
<div class="container">

<div class="topnav">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
</div>
</div>




</body>
</html>


...全文
114 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
karen99 2019-08-22
  • 打赏
  • 举报
回复
非常感谢你的回复
usecf 2019-08-13
  • 打赏
  • 举报
回复
1.一种方式你要用百分比设置 2.你需要设置手机适配 <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧