首页 > 解决方案 > 网站在移动设备上不显示任何 CSS 样式

问题描述

大家好,我对 HTML 等完全陌生。我整天都在努力使我的网站成为一个有趣的项目。在桌面上一切正常,但在移动设备上它不接受任何 CSS 更改。(背景,图片上的文字,文字颜色等。)我希望你能帮助我。我的主页是:https ://julianjonathanjohnson.ch/

  What have I tried so far: 
- images reduced to far below 5Mb
- body{background:green}
body:after{content: "mobile"}


@media screen and (min-width:481px){
    body{background:blue}
    body:after{content: "481px and larger"} 
}
@media screen and (min-width:769px){
    body{background:red}
    body:after{content: "769px and larger"} 
}

我的 HTML 是:(我认为是一团糟,但对我来说秩序混乱:D)

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> DogeWall </title>
    
    <script src="js.js"></script>
    
    <link rel="stylesheet" href="CSS.css"> 

    
</head>



<body id="page-wrap">
  
 <h1>Hello dear DOGE HODLER <br> Welcome to DogeWall <br> the hall of fame <br> for the first to walk on the moon.</h1>


        <ol>
<li class="P1">
         
<div class="TxtBild1">
        
        <img src="Bilder/MoonBg.jpg"  width="500" height="300">
        <span> <strong> citation example: Name: Date:  <br>
        <em> "To the moon and much further"</em></strong> </span>
        <span1> <ul>
            <strong>I take with me <br> to the MOON: </strong> 
            <li>Toiletpaper</li>
            <li>Fish snacks</li>
            <li>Bulldozer</li>
            <li> I donated <br> xxxyyz DOGE</li>
        </ul> </span1></div></li>
        
        <li class="P2">
         
<div class="TxtBild2">
        
        <img src="Bilder/MoonBg.jpg"  width="500" height="300">
        <span> <strong> citation example: Name: Date:  <br>
        <em> "To the moon and much further"</em></strong> </span>
        <span2> <ul>
            <strong>I take with me <br> to the MOON:</strong> 
            <li>Toiletpaper</li>
            <li>Fish snacks</li>
            <li>Bulldozer</li>
            <li> I donated <br> xxxyyz DOGE</li>
        </ul> </span1></div></li>
    
    </ol></body></html>

我的 CSS 是:

#page-wrap {
    width: 800px;
    margin: auto;
}

body {
    background-image:url("Bilder/MoonBg.jpg") ;
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
   
    color: bisque;
    
    
}
h1 {
    text-align: center;
}
.TxtBild1 {
    width: 500px;
    height: 300px;
    position: relative;
    border: 5px solid rgb(0, 0, 0);
    
    
}
.TxtBild1 span {
    background-color: silver;
    background-color: hsla(0, 0%, 100%, 0.5);
    position: absolute;
    bottom: 5%;
    width: 100%;
    height: 20%;
    line-height: 2em;
    text-align: center;
    font-family: Garamond, serif;
  border-radius: 50%;
    
}
.TxtBild1 img{
    display: block;
    
}
span1 {
    position: absolute;
    top: 0;
    line-height: 2em;
    text-align: center;
    font-family: Garamond, serif;
  border-radius: 50%; 
}


.TxtBild2 {
    width: 500px;
    height: 300px;
    position: relative;
    border: 5px solid rgb(0, 0, 0);
    
    
}
.TxtBild2 span {
    background-color: silver;
    background-color: hsla(0, 0%, 100%, 0.5);
    position: absolute;
    bottom: 5%;
    width: 100%;
    height: 20%;
    line-height: 2em;
    text-align: center;
    font-family: Garamond, serif;
  border-radius: 50%;
    
}
.TxtBild2 img{
    display: block;
    
}
span2 {
    position: absolute;
    top: 0;
    line-height: 2em;
    text-align: center;
    font-family: Garamond, serif;
  border-radius: 50%; 
}

PS:我的项目计划是让它在任何地方看起来都应该像在桌面上一样简单。

我希望能够轻松地复制带有文本的单个图像,但仍然可以轻松地更改它们的颜色、背景等,所以我认为我目前的混乱外观方法很容易改变。

友好的问候朱利安

编辑:问题被发现并且很有趣,代码都很好,我的移动设备是问题,其他手机工作正常,当我在手机上使用 icognito 时它也工作,最后是谷歌选项的问题。

标签: htmlcssmobileinvisiblewebsite-homepage

解决方案


你用的是什么类型的编辑器?你缺少一个开始<head>标签。 https://jsfiddle.net/qy58gwdu/ 应该可以...


推荐阅读