gpt4 book ai didi

php - CSS - PHP header 包含文件不适合设备大小/达到整个宽度

转载 作者:太空宇宙 更新时间:2023-11-04 13:16:24 24 4
gpt4 key购买 nike

以下代码是包含网站 header 的包含文件的一部分。

<head>
<link rel="shortcut icon" href="favicon.ico">
<meta charset="utf-8" />
<title>Test Site | Foo The Bar </title>
<link rel="stylesheet" href="csss_standard.css">
</head>

<body>

<div id="big_wrapper">



<header id="Header">
<a href="homepage.php"><img src="home_page_art.png" alt="Logo"></a>
</header>

<div id="navigation">
<ul>
<li id="page_1"><a href="page1.php">Page 1</a></li>
|
<li id="page_2"><a href="page_2">Page 2</a></li>
|
<li id="Page_3"><a href="page_3.php">Page 3</a></li>
|
<li id="page_4"><a href="page_4">Page 4</a></li>
|
<li id="news"><a href="news_and_such.php">Page 5</a></li>

</ul>
</div>

</div>

<br>
<br>

</body>

在桌面网站上,这看起来很棒。一切大小合适。但是当涉及到在移动网站上获取它时,该网站的大小似乎与我放置所有内容的中央“主要内容”div 相适应。 div 是一列,其宽度明确声明为 1000px,如下所示。

#meat_and_potatoes{
display:block;
text-align:center;
padding: 15px;
width:1000px;
text-align:center;
margin-left:auto;
margin-right:auto;
float:center;
background:#D8D8D8;
box-shadow: 1px 0px 20px 0px rgba(50, 50, 50, 0.75);

}

header 和 #Header div css 下面。

#Header{
margin: 0px 0px;
display:block;
width:105%; <!-- this was originally not a property. I was toying around with it to no avail... -->

/* orange gradiant */

background: rgb(255, 180, 0);
background: -moz-linear-gradient(90deg, rgb(255, 180, 0) 51%, rgb(255, 216, 0) 100%);
background: -webkit-linear-gradient(90deg, rgb(255, 180, 0) 51%, rgb(255, 216, 0) 100%);
background: -o-linear-gradient(90deg, rgb(255, 180, 0) 51%, rgb(255, 216, 0) 100%);
background: -ms-linear-gradient(90deg, rgb(255, 180, 0) 51%, rgb(255, 216, 0) 100%);
background: linear-gradient(180deg, rgb(255, 180, 0) 51%, rgb(255, 216, 0) 100%);

height: auto;
float:left;
padding-left:10px;
}



header, section, footer, aside, nav, article, hgroup{
display:block;
}

正如我上面所说,移动 View 会自动适应这个中心 div。移动设备是否喜欢明确声明的宽度?问题可能出在 .inc 中的 header 代码中吗? (我相当怀疑它只是因为我已经在几乎每个 div 标签下面的实际页面中测试了源代码)这可能是移动与桌面 CSS View 的问题吗? (例如“屏幕”rel 类型)

我意识到这个问题有很多变化的部分,所以如果需要其他东西,请告诉我。

最佳答案

Andrew 希望这能让您更好地了解应该为其编写媒体查询的大小:-

/* 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 */
}

根据您也想迎合的受众编写媒体查询,如果我只写一个,我会选择第一个,因为它涵盖了大多数智能手机。请继续并清除您的任何疑问,并问我您对此有何看法。很乐意进一步帮助您。

关于php - CSS - PHP header 包含文件不适合设备大小/达到整个宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24378127/

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