- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在我的网站上,我添加了媒体查询以使其响应智能手机/平板电脑,并且在我测试时它完美运行。突然,当我第二天回来时,我在网站上的所有 CSS 都乱七八糟,解决它的唯一方法是删除网站上的媒体查询。我相信问题出在我指定网站的宽度和高度时。这是媒体查询代码
媒体查询代码:
@media (min-height: 1366px) and (min-width: 1024px) {
#img-div{
width: 15%;
height: 20%;
margin: 0 auto;
overflow: hidden;
}
#container{
width: 100vw;
height: 100%;
margin: 0 auto;
position: relative;
top: 20%;
}
#login-div{
width: 39vw;
height: 100%;
margin: 0 auto;
overflow: hidden;
}
.input-box{
width: 100%;
height: 60px;
background-color: rgba(255, 255, 255, 0.25);
border: none;
padding: 5px 20px;
border-style: none;
margin: 0 auto;
font-size: 16px;
box-sizing:border-box;
}
#welcome-text{
text-align: center;
font-size: 25px;
}
}
@media (min-height: 1024px) and (min-width: 768px){
#container{
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
top: 0%;
}
#login-div{
width: 39vw;
height: 100%;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 20%;
}
#welcome-text{
text-align: center;
font-size: 20px;
position: relative;
top: 20%;
}
#img-div{
width: 15%;
height: 10%;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 20%;
}
}
@media (min-height: 812px) and (min-width: 375px){
#img-div{
width: 15%;
height: 10%;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 12%;
}
#welcome-text{
text-align: center;
font-size: 16px;
position: relative;
top: 12%;
}
#login-div{
width: 78vw;
height: 100%;
margin: 0 auto;
position: relative;
top: 12%;
}
#forgotPass{
position: relative;
left: 15%;
}
#remember{
margin: 0;
padding-left: 12%;
padding-top: 1%;
}
}
@media (min-height: 375px) and (min-width: 812px){
#img-div{
width: 6%;
height: 10%;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 5%;
background-color: ;
}
#welcome-text{
text-align: center;
font-size: 18px;
position: relative;
top: 1%;
}
#login-div{
width: 39vw;
height: 100%;
margin: 0 auto;
position: relative;
top: 0%;
}
.bottom-text{
float: left;
position: relative;
bottom: 5%;
}
}
我使用 min-height/width 因为当你水平翻转屏幕时,一些查询具有相同的宽度所以我必须指定。所以我的问题是,当我编辑手机/平板电脑的媒体查询时,它现在和以后我回来时,网站本身(不在手机上)看起来都乱七八糟。如果有人能告诉我使您的网站在手机上响应的最佳方法,那就太好了。这是我的网站代码
HTML 和一些 PHP
<?php
if($_SERVER['REQUEST_METHOD'] =="POST"){
$error = "";
$fullname = addslashes(trim($_POST['fullname-text']));
$email = addslashes(trim($_POST['email-text']));
$password = addslashes(trim($_POST['password-text']));
$storePassword = password_hash($password, PASSWORD_BCRYPT, array('cost' => 10));
if(!empty($fullname) && !empty($email) && !empty($password)){
//Check if email is valid
if(filter_var($email, FILTER_VALIDATE_EMAIL) == false){
$error .= "Email not VALID";
}
//Check if passwrod is greater 6
if(strlen($password) < 6){
die ("Password has to be GREATER than 6 characters!");
}
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rotary Speaker Login Page</title>
<link rel="stylesheet" type="text/css" href="rotarycss.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>
<body>
<div id="tint">
<div id="container">
<div id="img-div">
<img src="yellow.png" id="logo">
</div>
<p id="welcome-text">Welcome to the Guest Speaker Forum</p>
<div id="login-div">
<form action="signup.php" method="post">
<input type="text" name="fullname-text" placeholder="Fullname" class="input-box" class="test">
<br><br/>
<input type="text" name="email-text" placeholder="Email" class="input-box">
<br><br/>
<input type="password" name="password-text" placeholder="Password" class="input-box">
<br><br/>
<button class="submit" name="submit">SIGN UP</button>
<br><br/>
<a href="login.php" class="href-links"><p class="bottom-text">Already have an account?</p></a>
<br><br/>
<a href="http://www.google.com" class="href-links"><p id="goBack" class="bottom-text">← Back to Website</p></a>
</form>
</div>
</div>
</div>
</body>
</html>
CSS
html {
background-image: url(speaker.png);
background-attachment: fixed;
background-size: 100% 100%;
}
html, body {
min-height: 100%;
min-width: 100%;
color: hsla(0,0%,100%,.8);
font-family: 'Montserrat', sans-serif;
overflow: hidden;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-o-user-select: none;
user-select: none;
margin: 0;
padding: 0;
}
#tint{
z-index: 1;
height: 100%;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
background: rgba(0, 0, 0, 0.5);
}
#container{
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
top: 0%;
background-color: ;
}
#img-div{
width: 8%;
height: 15%;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 12%;
}
#logo{
width: 100%;
height: 100%;
}
#welcome-text{
text-align: center;
font-size: 23px;
position: relative;
top: 12%;
}
#login-div{
width: 29vw;
height: 100%;
margin: 0 auto;
position: relative;
top: 12%;
background-color: ;
}
.input-box{
width: 100%;
height: 40px;
background-color: rgba(255, 255, 255, 0.25);
border: none;
padding: 5px 20px;
border-style: none;
margin: 0 auto;
font-size: 20px;
box-sizing:border-box;
color:white;
}
input::-webkit-input-placeholder {
color: white !important;
}
.checkBox{
width: 25px;
position: relative;
float:left;
}
.checkBox label{
cursor: pointer;
position: absolute;
width: 25px;
height: 25px;
top:0px;
left: 0px;
background: #eee;
border: 1px solid #ddd;
}
.checkBox label:after{
opacity: 0.2;
content: '';
position: absolute;
width: 9px;
height: 5px;
background: transparent;
top: 6px;
left: 7px;
border: 3px solid #333;
border-top: none;
border-right: none;
transform: rotate(-45deg);
}
.checkBox label:hover:after{
opacity: 0.5;
}
.checkBox input[type=checkbox]:checked + label:after{
opacity: 1;
}
#remember{
margin: 0;
padding-left: 7%;
padding-top: 1%;
}
.submit{
background-color: orange;
border: none;
padding: 10px 27px;
width: 100%;
height: 50px;
color: hsla(0,0%,100%,.8);
font-size: 20px;
}
.bottom-text{
float: left;
}
.bottom-text:hover{
text-decoration: underline;
}
#forgotPass{
position: relative;
left: 55%;
}
#goBack{
clear: both;
}
.href-links{
color: hsla(0,0%,100%,.8);
}
添加媒体查询后的样子
最佳答案
您的媒体查询太具体了,您需要满足于 3 个,也许 4 个,并使它们都正常工作。我只会在移动纵向模式下使用最大高度,除此之外没有必要,它只会导致您在不同的屏幕上出现问题。拥有 3 种看起来像您想要的基本尺寸(sm、md、lg)比拥有 7 种有缺陷的尺寸要好。
您必须重新检查您的@media 尺寸,它们看起来有点奇怪:您的高度都大于宽度,只有手机或平板电脑才需要。
此外,在对象放置(顶部、底部等)等方面使用如此多的百分比会导致您不断遇到不同设备的问题,在 px 中建立它并从那里开始工作更容易。对于宽度,可以使用 %,但要注意不要将它们与 vw 混合使用,因为同样会引起麻烦。
如果你在 fiddle 上分享它会很理想。
关于php - 媒体查询与网站 CSS 混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48121543/
似乎最近我看到越来越多的人开始在他们的样式表中使用 media="all" 而不是 media="screen"。 我的问题是什么时候应该使用 media="all" 而不是 media="scree
我正在尝试使用 https://www.instagram.com/developer/endpoints/media/ ,但对于我使用的每个媒体 ID,我总是得到相同的结果: { "meta
哟,我正在为服务器制作一个 MOTD 供最终用户阅读。但是,对于使用较小显示器的用户来说,它看起来非常压缩,例如,当分辨率为 1280x1040 时,它会被拉低。我不熟悉 CSS 中的 @media
我在我的 CSS 文件中使用了 @media screen 而不是 (-webkit-min-device-pixel-ratio:0)。我的问题是关于指定的值,即在这种情况下为“0”。值的变化将如何
我正在播放 Activity 中的视频,我需要显示/隐藏顶部栏 View 以及媒体 Controller 。所以当媒体 Controller 在屏幕上时,我的顶部 View 应该是可见的,当媒体 Co
我在我的 WordPress 主题中创建了一个小部件来显示图像。到目前为止,小部件可以工作,我可以输入值并在前端显示这些值。 当我选择一个小部件并将其放入小部件区域时,媒体上传按钮不起作用。在 Wor
我正在使用MWFeedParser从此处读取Youtube原子供稿:here xml代码: 我如何获取媒体的网址:缩略图? 我试图更改MWFeedParser.m 由此: else if ([cu
当使用 Python 向 Instagram API 发出 GET 请求时,传递所需的变量,如下所示 photos = api.media_search(lat=latitude, lng=longi
我正在使用与媒体播放器关联的媒体 Controller 来播放声音。问题是媒体 Controller 一旦失去焦点就会隐藏起来。我有一个按钮,按下时会播放声音,媒体 Controller 会出现在屏幕
我有一个媒体播放器并与它关联了一个媒体 Controller 。控件工作正常。 我遇到了两个问题: 当媒体 Controller 获得焦点时,即用户触摸它然后触摸屏幕的另一部分时,媒体 Control
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在对话框中显示一个 VideoView 并向其附加一个媒体控件。 但是当我尝试点击媒体控件(播放、搜索栏等)时,对话框会消失。 媒体控制按钮不会被点击,而是将点击注册为 Dialog 的 Outsi
我目前正在使用 HTML 编写可打印文档,它将显示从数据库中提取的数据。我的想法是我将使用 HTML/CSS 使文档看起来不错,但它将专门用于打印。 文档的布局使用表格来控制数据库中数据的显示方式。
我需要在网络应用程序中打印我的报告。 我有在我的代码中。但它不应用任何样式。另一方面,如果我使用 在文档中编写 print.css 代码一切正常。 怎么了? 最佳答案 也许你在主样式之前插入打印样式
CSS html{ overflow-y:scroll; } js function showW(){ var a=($(window).width()); $('#
我编写了一个 Chrome 扩展程序,其中一个功能是您可以在您所在的页面中调出一个帮助面板,其中包含其使用指南。这个帮助面板是通过JS插入到页面中的,它的CSS都是通过$('#selector_for
我需要为 WORM 媒体开发归档软件。 这种类型的媒体允许通常的访问操作:读取、写入,但文件一旦写入,就无法修改或删除。 因为这样的媒体可能很昂贵,我想知道如何在开发阶段为测试创建一个假的 WORM
下面的这个 Activity 工作正常,但 mediaController 仅在我单击屏幕时显示。第二个问题是媒体 Controller 只显示 3 秒。我应该怎么做才能消除这个问题? public
我正在使用 VideoView 播放本地 mp4,我也在使用 MediaController。媒体控制栏未显示在我的视频剪辑下方,而是显示在屏幕中间。我使用 setAnchorView 将其附加到我的
我的布局包含 videoView 还有java代码中的Medicontrolleri: final MediaController mediaCont
我是一名优秀的程序员,十分优秀!