gpt4 book ai didi

css - 无法让媒体查询工作

转载 作者:行者123 更新时间:2023-11-28 08:08:04 24 4
gpt4 key购买 nike

我创建了一个大部分响应式的网站,但在较小的屏幕上查看时需要一点帮助。我尝试向 css 页面添加 @media 查询,但它似乎没有任何区别。

我只在我的主 css 页面中添加了不同的样式规则,并没有在我的 html 中添加任何内容。我对媒体查询的确切工作方式感到困惑,所以这可能是我的问题?

这是我的CSS

/*Alt styles for smaller screens*/
@media only screen and (max-width: 780px) {

div.price-area1 {
width: 100%;
text-align: center;
}

div.price-area2 {
width: 100%;
text-align: center;
}

div.price-area3 {
width: 100%;
}

input.submit {
width: 60%;
margin-left: 20%;
}

nav {
width: 100%;
}

nav ul li {
position: relative;
float: left;
width: 50%;
font-family: 'Poiret One', cursive;
margin-bottom: 15px;
text-align: center;
font-size: 24px;
}
}

最佳答案

理解媒体查询最简单的方法是阅读它herehere :

话虽如此,您可能希望使用诸如 bootstrap 之类的框架这是启动网站的好方法。否则,您可以将此模板用于媒体查询:

/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}

/* iPads (landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}

/* Desktops and laptops ----------- */
@media only screen and (min-width : 1224px) {
/* Styles */
}

/* Large screens ----------- */
@media only screen and (min-width : 1824px) {
/* Styles */
}

/* iPhone 4 ----------- */
@media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {
/* Styles */
}

如果您想自己完成这一切,这是一个很好的起点。

关于css - 无法让媒体查询工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29404312/

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