gpt4 book ai didi

html - 响应式网页

转载 作者:行者123 更新时间:2023-11-28 17:29:52 26 4
gpt4 key购买 nike

我已经添加了我的 html 代码和我的 CSS,我很困惑如何让这个网页响应,所以当用户在不同的设备上时,网页会自动缩放到他们的设备。 (很抱歉,如果这是一个重复的问题,我找不到答案)。

       footer {
margin: 50px 0;
}

.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}

.fade:hover {
opacity: 0.5;
}

h1 {
margin: .67em 0;
font-size: 2em;
font-family: 'Dosis', sans-serif;
}

body {
font-family: 'Dosis', sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333;
background-color: #fff;
padding-right: 5px;
}

body {
max-width: 1000px;
margin: 10px auto;
}

body {
font-family: 'Dosis', sans-serif;
}

body {
background: white;
}

.container {
max-width: 100%;
text-align: center;
}

.centre {
position: relative;
display: inline-block;
float: left;
max-width: 100%;
padding: 50px;
}

ul {
max-width: 100%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
max-width: 100%;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

a:hover:not(.active) {
background-color: #111;
}

.active {
background-color: #4CAF50;
}

.accordion {
width: 895px;
height: 485px;
max-width: 100%;
overflow: hidden;
box-shadow: 0 10px 6px -6px #111;
margin: 20px auto
}

.accordion ul {
width: 200%;
max-width: 100%;
}

.accordion li {
position: relative;
display: block;
width: 160px;
max-width: 100%;
float: left;
box-shadow: 0 0 30px 8px #222;
transition: all 0.4s ease .300ms;
}

.accordion ul:hover li {
width: 40px
}

.accordion ul li:hover {
width: 640px
}

.caption {
background: rgba(0, 0, 0, 0.5);
position: absolute;
bottom: 0;
width: 640px
}

.caption a {
display: block;
color: #fff;
text-decoration: none;
font: normal 16px'Lato', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
padding: 10px;
}

.center {
align-content: center;
}

.thumbnail {
display: block;
padding: 4px;
padding-left: 5px;
margin-bottom: 20px;
line-height: 1.42857143;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
-webkit-transition: border .2s ease-in-out;
-o-transition: border .2s ease-in-out;
transition: border .2s ease-in-out;
}

.thumbnail > img,
.thumbnail a > img {
margin-right: auto;
margin-left: auto;
}

a.thumbnail:hover,
a.thumbnail:focus,
a.thumbnail.active {
border-color: #337ab7;
}

.thumbnail .caption {
padding: 9px;
color: #333;
}
<body>

<nav class="contain">
<div>
<div>
<ul>
<li><a class="active" href="index.html">Home</a>
</li>
<li><a href="Nike_Shoes1.html">Mens Shoes</a>
</li>
<li><a href="women_clothing.html">Womens Shoes</a>
</li>
<li><a href="boys_clothing.html">Boys Shoes</a>
</li>
<li><a href="boys_clothing.html">Girls Shoes</a>
</li>
</ul>
</div>

</div>

</nav>


<div class="container">

<div>


<div>

<div class="accordion">
<ul>
<li>
<div class="caption"><a href="#">Slide 1</a>
</div>
<a href="#">
<img src='Slider_Image1.jpg' />
</a>
</li>

<li>
<div class="caption"><a href="#">Slide 2</a>
</div>
<a href="#">
<img src='Slider_Image2.jpg' />
</a>
</li>

<li>
<div class="caption"><a href="#">Slide 3</a>
</div>
<a href="#">
<img src='Slider_Image3.jpg' />
</a>
</li>

</ul>
</div>

</div>

<div>

<div class="centre , fade ,">
<div>
<a href="Nike_Shoes1.html">
<img src="Image1.jpg" alt="">
</div>
</div>

<div class="centre , fade">
<div>
<a href="Nike_Trainers.html">
<img src="Image2.jpg" alt="">

</div>
</div>

<div class="centre , fade">
<div>
<img src="Image3.jpg" alt="">
</div>
</div>


<div class="centre , fade">
<div>
<a href="boys_clothing.html">
<img src="Boys_Clothing.jpg" alt="Boys Clothing">
</div>
</div>





</div>

</div>

</div>

</div>

</div>


<div>
<!-- Footer -->
<footer>



</footer>

</div>

最佳答案

您可以通过向 css 文件添加媒体查询来使页面响应,例如:

@media(max-width: 800px){
/* Add mobile styles here */
}

你可以在这里看到更多关于媒体查询的信息,因为有很多可用的配置:https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries

关于html - 响应式网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37072363/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com