html – 修改网页,使其更具移动性/平板电脑兼容性

所以,

我正在寻找一些帮助,使一个相当简单的页面更多的移动/平板电脑友好,因为目前在某些移动设备上它看起来很丑陋:S

我已经尝试正确定位的东西,使用像素而不是百分比,因为我只是在每个角落(顶部和底部的条)真正做的东西,我已经尝试纳入一些缩放以及代码,使图像不显示某些屏幕宽度

任何人都可以帮助纠正我的html / css,使其完全兼容,因为它在我做出改变时永远不会起作用.

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta content="true" name="HandheldFriendly" />
    <meta content="width=device-width" name="viewport" />
    <meta content="width=device-width,initial-scale=0.75" name="viewport" />
    <title>Website.com</title>
    <link href="testing.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header_container">
        <div id="header">
            <div class="headimage">
                <a href="http://website.com/" target="_blank">
                    <img alt="" class="headimager" src="http://placehold.it/350x95/" />
                </a>
            </div>
            <select class="class-selector">
                <option value="">- Testing Dropdown -</option>
            </select>
            <div class="classcycler"><a href="javascript: void(0);" id="NextPage"><font color="#EFEFEF">Next Page</font></a>  <font color="red">|</font>  <a href="javascript: void(0);" id="PreviousPage"><font color="#EFEFEF">Previous Page</font></a>
            </div>
            <div class="classcycler2"><a class="downclass" href="javascript: void(0);"><font color="#EFEFEF">Scroll Down</font></a>  <font color="red">|</font>  <a class="upclass" href="javascript: void(0);"><font color="#EFEFEF">Scroll Up</font></a> 
            </div>
            <div class="headright"><a class="TOPJS" href="javascript: void(0);"><font color="#EFEFEF">Up to Top</font></a> 
                <br/> <a class="KEYJS" href="javascript: void(0);"><font color="#EFEFEF">Down to Bot</font></a> 
            </div>
        </div>
    </div>
    <div id="container">
        <table id="gradient-style" summary="">      <tbody><thead><tr><th colspan="30">Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>></th></tr></thead></tbody></table>
    </div>
    <div id="footer_container">
        <div id="footer">
            <div class="footimage">
                <a href="http://website.com/" target="_blank">
                    <img alt="" class="footimager" src="http://placehold.it/350x95/" />
                </a>
            </div>
            <div class="footleft">
                <a class="def" href="javascript: void(0);"></a>
            </div>
            <div class="footright">
                <a class="abc" href="javascript: void(0);"></a>
            </div>
        </div>
    </div>
</body>
</html>

CSS

body {
    background: #F0F0F0;
    line-height: 1.6em;
    margin: 0;
    overflow-x: scroll;
    padding: 0;
}

#header_container {
    background: url(gradhead.png) repeat-x #111625;
    border: 0 solid #666;
    height: 80px;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
}

#footer .headimage {
    position: relative;
}
#header .headright {
    font-size: 20px;
    position: fixed;
    right: 10px;
    text-align: right;
    top: 15px;
}

#header .class-selector {
    left: 10px;
    position: fixed;
    top: 5px;
}

#header .classcycler {
    font-size: 20px;
    left: 10px;
    position: fixed;
    top: 30px;
}

#header .classcycler2 {
    font-size: 20px;
    left: 10px;
    position: fixed;
    top: 50px;
}

#container {
    margin: 0 auto;
    padding: 80px 0;
    width: 100%;
}

#footer_container {
    background: url(gradhead.png) repeat-x #111625;
    border: 0 solid #666;
    bottom: 0;
    height: 80px;
    left: 0;
    position: fixed;
    width: 100%;
}

#footer .footleft {
    font-size: 20px;
    left: 10px;
    position: absolute;
    top: 10px;
}

#footer .footright {
    font-size: 20px;
    position: absolute;
    right: 10px;
    top: 10px;
}

#footer .footimage {
    position: relative;
    top: -13px;
}

#footer .footleft a {
    background: url(http://placehold.it/60x60/) no-repeat;
    display: block;
    height: 60px;
    width: 60px;
}

#footer .footleft a:hover {
    background: url(http://placehold.it/60x60/000) no-repeat;
}

#footer .footright a {
    background: url(http://placehold.it/60x60/) no-repeat;
    display: block;
    height: 60px;
    width: 60px;
}

#footer .footright a:hover {
    background: url(http://placehold.it/60x60/000) no-repeat;
}

#header,#footer {
    color: #ECECEC;
    height: 100%;
    margin: 0 auto;
    position: relative;
    text-align: center;
    width: 100%;
}

@media screen and max-width 600px {
    .headimager {
        display: none;
    }
}

@media screen and max-width 450px {
    .footimager {
        display: none;
    }
}

没有jsfiddle链接的原因是因为它不允许我放入元标记.

JavaScript的

$("a.def").click(function () {
    $('body').animate({
        "scrollLeft": "-=404"
    },200);
});

$("a.abc").click(function () {
    $("body").animate({
        "scrollLeft": "+=404"
    },200);
});

解决方法

移动/平板设备有几种方式可以与您的网站一起使用.

固定设计

创建一个在所有格式上一般工作的样式表.您的网站在所有设备上都会显示相同,但​​这个过程将是最简单的解决方案.

固定设计过程应主要使用百分比和最大宽度来创建根据设备宽度而更改的内容.

PROS

使用良好时,此过程使用最少的资源,并且更快地创建和修改.

缺点

如果您的网站在网页上拥有大量内容,那么您的网站可能会在较小的设备上变得非常狭窄

响应设计

如果您希望在不同的设备上对您的网站进行不同的选择,并且可以说是最佳的,那么您需要一个响应式设计.这可以通过使用动态样式表或通过为不同的设备使用多个样式表来实现.

PROS

一个非常通用的网站,可以基于观看设备独特和最佳地显示.

缺点

更大的或额外的资源和稍微更长的负载取决于设计.更长的开发和修改时间.

创造有力的CASCADING STYLESHEETS

使用设置宽度是不再可行的,因为有简单到许多可变大小.
答案是灵活的一切.

>在您的示例中使用视口元标记来定位设备
这是访问您的网站.

< meta name =“viewport”
含量=“宽度=设备宽度,初始规模= 1.0,最小刻度= 1.0,最大规模= 1.0,用户可扩展=无” />

对于视口元标签显然有需求,因为它被大多数流行的移动浏览器支持并被数千个网站使用.
>使用媒体查询.

媒体查询可让您为特定的屏幕宽度编写单独的规则.

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

>使用Javascript.

除了bootstrap之外,一个很好的javascript解决方案是jquery mobile,它通过为您的工作做好了设计响应网站的时间和精力.
你不需要知道或编辑任何javascript来使用它.

SPECIFICS

所以现在我们有选择让我们来看看你的具体问题.
您的网站实际上似乎已经很响应了.并且使用固定设计为移动和PC设计了良好的布局.

更改您的媒体查询(他们不使用括号)

@media screen and max-width 600px {
    .headimager {
        display: none;
    }
}

@media screen and max-width 450px {
    .footimager {
        display: none;
    }
}

@media screen and (max-width:600px) {
    .headimager {
        display: none;
    }
}

@media screen and (max-width:450px) {
    .footimager {
        display: none;
    }
}

我建议不要使用表(#gradient-style).一个简单的100%div(#container)将使用浮动或%宽度嵌套元素来做到这一点.
还有容器中的文本不会自动换行,没有间距的css wordwrap:break;

除此之外,没有更明显的问题,但如果需要特定的更改,请添加评论.

相关文章

HTML代码中要想改变字体颜色,常常需要使用CSS样式表。CSS是...
HTML代码如何让字体盖住图片呢?需要使用CSS的position属性及...
HTML代码字体设置 在HTML中,我们可以使用标签来设置网页中的...
在网页设计中,HTML代码的字体和字号选择是非常重要的一个环...
HTML(Hypertext Markup Language,超文本标记语言)是一种用...
外链是指在一个网页中添加一个指向其他网站的链接,用户可以...