html - CSS 动态调整大小
问题描述
HTML:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title> Dummy Site | Home</title>
<link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
<header>
<div class="container">
<div id="branding">
<img src="https://i.imgur.com/MPoWmYb.png"></img>
<h1>Title</h1>
<h3>This is my description</h3>
</div>
<nav>
<ul>
<li class="current"><a href="index.html">Home</a></li>
<li><a href="page1.html">Page 1</a></li>
<li><a href="page2.html">Page 2</a></li>
<li><a href="page3.html">Page 3</a></li>
</ul>
</nav>
</header>
<section id="frontImage">
<div class="frost">
<h3></h3>
</div>
</section>
<footer>
<p>Name, 2018</p>
</footer>
</div>
</body>
</html>
CSS:
body{
font:15px/1.5 Arial, Helvetica, sans-serif;
padding:0;
margin:0;
background-color:gray;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
width: 100%;
height: 100%;
text-align: center;
}
/* Global */
.container{
width: 80%;
margin:auto;
overflow:hidden;
}
ul{
margin:0;
padding:0;
}
/* Header and logo */
header{
top:0;
color:#ffffff;
background: inherit;
box-shadow: inset 0 0 0 200px rgba(0,0,0,0.75);
}
header #branding{
text-align: center;
}
header #branding h1{
min-width: 200px;
margin-left: 43.5%;
margin-right: 43.5%;
margin-bottom: 5px;
border: solid 4px #ffffff;
}
header #branding h3{
margin-top:0;
}
header nav{
text-align: center;
margin-bottom: 10px;
}
header li{
padding: 0 30px 0 30px;
display: inline;
}
header li a{
font-family: Verdana;
font: bold;
text-decoration: none;
color:#ffffff;
}
header li:hover{
border: 2px solid #ffffff;
}
header #branding img{
border: solid 2px #ffffff;
top:1%;
left: 3%;
width:130px;
height:130px;
position: absolute;
}
.frost{
top: 16.5%;
left:0;
text-align: center;
color:#ffffff;
width:40em;
height:47.65em;
position:absolute;
background: inherit;
overflow: hidden;
margin: 0px auto;
z-index: 1;
}
.frost:before{
position: absolute;
top: -20px;
left: -70px;
bottom: 0;
z-index: 0;
width: 200%;
height: 200%;
background-position: 50% 0;
content: "";
box-shadow: inset 0 0 0 3000px rgba(255,255,255,0.1);
filter: blur(25px);
z-index: -1;
}
footer{
position: absolute;
bottom: 0;
height:4.55em;
width: 100%;
color:#ffffff;
text-align: center;
background: inherit;
box-shadow: inset 0 0 0 200px rgba(0,0,0,0.75);
}
Codepen 示例: https ://codepen.io/anon/pen/dQeeRG
大家好,
我目前正在构建一个网站,但是我似乎无法让它使用浏览器窗口(Chrome)动态调整大小。
我尝试过使用定位以及将容器设置为 80% 并在元素上设置边距等,但是诸如徽标之类的东西不会调整大小,“霜”元素也不会调整。
我暂时尝试在没有 Javascript 的情况下执行此操作,因为我正在学习这一点。
需要注意的是,.frost 的功能只是显示磨砂玻璃效果。
欢迎任何意见/建议。
解决方案
我不清楚你到底想得到什么,但这种布局的问题是类的绝对宽度.frost
,即 40em。删除它或将其更改为 100%,然后您将获得响应式布局。
推荐阅读
- java - Apache POI 5 生成具有 30 多列的 Word 表
- spring-boot - Spring Boot - MongoTemplate:过滤嵌套对象
- docusignapi - DocuSign Webhook 连接中的标头键
- groovy - 需要将 JMS_IBM_LAST_MSG_IN_GROUP 属性设置为 true 以使用 JMeter 进行 IBM MQ 测试
- neovim - 如何让 Ctrl+h 映射在 NeoVim 中工作
- python - 从上下文管理器中止执行 with 语句
- javascript - 如何在 mat-card 中设置 mat-card-title 的样式
- ios - 单击单元格内的按钮时从 UICollectionView 中删除单元格
- woocommerce - 向站点管理员添加电子邮件通知以在 Woocommerce 中更改自定义订单状态
- python - 通过 ffmpeg 发布时的视频色差