固定宽度或基于百分比的网站设计

如何解决固定宽度或基于百分比的网站设计

| 我的问题是非常基本和通用的。 我开始使用div标签设计页面。现在我对两种方法感到困惑。 我应该保持div的宽度和高度固定(即像素固定)还是 我应该保持divs变量的宽度和高度(即使用%代替像素)。 我个人喜欢第一种方法,该方法可以修复所有问题,并且在不同的屏幕分辨率下几乎没有任何东西受到干扰的可能性,但是缺点是,如果屏幕分辨率低于我期望的屏幕分辨率,那么滚动条会使网站看起来很糟糕(可能是还有更多缺点,但目前我不记得了:)),所以在这种情况下,第二种方法就出现了,但问题是,一旦您开始使用%作为宽度和高度,尽管设计了页面却很难设计更稳定。 我对这两种方法感到困惑,并且需要对以上两种方法进行投入... 提前致谢。     

解决方法

你是在自问自答。第二种方法在大多数情况下都更好,因为它可以很好地适合所有屏幕分辨率。想想什么时候有人尝试使用手机加载您的页面,然后使用百分比会有所帮助。 而且我不认为使用百分比会使设计变得更困难,甚至认为它更容易。例如,如果要将主表的宽度调整为屏幕的1/4,现在只需设置
width: 25%
,而不是设置(例如)
width: 250px;
,然后猜测它是否适用于此尺寸的显示器或其他尺寸的显示器。 想象一下,您当前正在使用17英寸笔记本电脑,并且页面布局的宽度固定设置为800px,适合当前屏幕。但是当您在24英寸显示器上运行该布局时,看起来像桌上的纸。 如果说百分比,那么70%可以安装17英寸笔记本电脑和24英寸显示器。 这是一个示例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\" />
<title>Untitled 1</title>
<style type=\"text/css\">

html,body{
    height:100%;
}

/* Backward Compatible for IE6 */
* html #container{
    height:100%;

}

/* Top logo and bottom footer */
div#logo,div#footer { 
    max-width: 90%; 
    color:#000000; background-color:#ffffff; 
    padding:10px 0px 10px 0px; 
    text-align:center; 
    margin-left:auto; margin-right:auto; 
}


/* Top navigation bar */
div#navbar {
    max-width: 90%; 
    color:#ffffff; background-color:#124a9f; 
    padding:10px 0px 10px 0px; 
    text-align:center; 
    margin-left:auto; margin-right:auto; 
}


/* Container for three lower boxes */

div#container {
    max-width: 90%; 
    height:70%; 
    color:#000000; background-color:#ffffff; 
    margin-bottom:10px; margin-left:auto; margin-right:auto; 
}


/* Main content (center box) */

div#main {
    overflow:auto; 
    height: 100%;  
    padding:10px 10px 0px 10px; 
    color:#000000; background-color:#efecf8; 
}

/* Full navigation menu (left box) */

div#leftcol { 
    float:left;
    width:10%; 
    height:100%; 
    padding:10px 10px 0px 10px;  
    color:#000000; background-color:#bfdbf7; 
}

/* Featured content (right box) */

div#rightcol { 
    float:right;
    width:10%; 
    height:100%;  
    padding:10px 10px 0px 10px;
    color:#000000; background-color:#bfdbf7;
}

</style>
</head>

<body>

<div id=\"logo\">
Logo
</div>

<div id=\"navbar\">
Navigation Bar
</div>

<div id=\"container\">

    <div id=\"leftcol\">Left Column</div>
    <div id=\"rightcol\">Right Column</div>
    <div id=\"main\">Lorem ipsum dolor sit amet,consectetuer adipiscing elit. Quisque tempor. Nam in libero vel nisi accumsan euismod. Quisque quis neque. Donec condimentum,enim convallis vestibulum varius,quam mi accumsan diam,sollicitudin ultricies odio ante vitae purus. Etiam ultricies quam. Vestibulum turpis turpis,fermentum ut,accumsan quis,tempor at,ipsum. Nam felis elit,sollicitudin id,ultrices faucibus,fringilla vel,dui. Aliquam tincidunt iaculis eros. Sed in lorem. Nullam eu enim. Quisque tristique pretium diam. Fusce tempor sollicitudin ligula. Donec purus eros,mattis quis,mattis vestibulum,congue quis,felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.
    Lorem ipsum dolor sit amet,felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.Lorem ipsum dolor sit amet,felis. Nulla facilisi. Nam ultricies posuere justo. In feugiat.
    </div>
</div>
<div id=\"footer\">
    &copy;2011 Ideal Web Design Co.
</div>
</body>

</html>
    ,这个问题实际上取决于这些div中将包含哪些功能。如果需要增长,则可能需要保证百分比。如果没有,那么您应该可以使用px     ,这完全取决于您要创建的网站的布局和设计。 第二种方法用于\“ fluid \”布局(需要扩展并占用所有可用空间的网站),否则与固定布局相比,您没有其他显着优势。 我建议您在这里查看W3C提供的屏幕分辨率的统计信息: http://www.w3schools.com/browsers/browsers_display.asp 如您所见,800x600几乎用完了,因此专注于1024x768及更高版本将有所帮助。 我不知道您进入学习过程有多远,但是当您想了解大多数开发人员的用途时,建议您访问960网格系统: http://960.gs/     ,我猜第一种方法对99%的wepapp更好。您可以查看Blueprint CSS框架,这是一种使用网格状布局的非常简单,干净的方法。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-