如何设计一个简单的网站首页

如何设计一个简单的网站首页

欢迎点击「算法与编程之美」↑关注我们!

本文首发于微信公众号:"算法与编程之美",欢迎关注,及时了解更多此系列文章。

问题描述

网站首页是一个网站的入口网页。对于一个网站的了解往往是通过他的首页。首页的主要作用就是引导互联网用户浏览网站其他部分的内容。网站首页上展现的这部分内容一般被认为是一个目录性质的内容。首页的作用是一个网站内容的汇总和索引,在首页上有很多图标和链接,栏目也比较多,就像以一个住宅的大门一样,由此通往各个模块,首页是网站必需的,不可或缺的。

解决方案

设计网页的时候我们需要考虑很多因素。首先我们需要知道网页上应该包含哪些内容。对于大部分网页上必须有的就是导航栏。当然关于本网站的相关信息即文字和图片这也当然必须有。此外我们还可以根据情况及网页设计需求考虑对于本网页的设计我们是否需要分栏。

网页设计框架有很多种,具体使用哪种就要结合网站需要,进行选择了。(现在的网页差不多都采用分列布局,常见的有单列布局、双列布局、三列布局和混合布局,超过三列的布局很少见。)本次网页的布局如下图所示:

图2.1网页布局

在这之后,我们还要考虑网页的主色调等等问题。之后,我们就可以用简单的代码将网页包含的相关信息显示出来。但此时因为没有设置css样式,所以此时网页显示出来的效果,我们可以看到并不好看。代码如下

代码语言:javascript复制div id="top_bg">

挑战与职责

那么的市场上了马车哦啊女款可惜那时快

那么的市场上了马车哦啊女款可惜那时快......(此处省略文字)

那么的市场上了马车哦啊女款可惜那时快......(此处省略文字)

动物世界

图2.2初步显示效果

要让网页变得好看,我们就需要设置css样式。(本次我们使用外联样式。)设置样式就包括字体样式,颜色,图片大小,边框等等。(常见的盒子模型当然不能忽略。)

代码语言:javascript复制*{

body{

background: #232524;

margin: 0;

padding: 0;

font-family: "宋体",arial,helvetica,sans-serif;

font-size: 12PX;

line-height: 1.5em;

width: 100%;

}

a:link,a:visited{

color: #069;

text-decoration: underline;

}

a:active,a:hover{

color: #990000;

text-decoration: none;

}

#top_bg{

width: 100%;

background: #7bdaae url(../img/top_bg.jpg)repeat-x;

height: 830px;

}

#container{

width: 900px;

margin: 0 auto;

}

#header{

width: 100%;

height: 280px;

}

#header_logo{

float: left;

display: inline;

width: 500px;

height: 20px;

font-family: tahoma,geneva,sans-serif;

font-size: 20px;

font-weight: bold;

color: #678275;

margin: 28px 0 0 15px;

padding: 0;

}

#header_logo span{

margin-left: 10px;

font-size: 11pz;

font-weight: normal;

color: #000;

}

#header_bottom{

float: left;

width: 873px;

height: 216px;

background: url(../img/header_bottom_bg.png)no-repeat;

margin: 15px 0 015px;

}

#menu{

float: left;

width: 465px;

height: 29px;

margin: 170px 0 0 23px;

display: inline;

padding: 0;

}

#menu ul{

list-style: none;

display: inline;

}

#menu ul li{

float: left;

padding-left: 20px;

padding-top: 5px;

}

#menu ul li a{

font-family: "黑体";

font-size: 16px;

color: #393;

text-decoration: none;

}

#menu ul li a:hover{

color: #fff;

background: #396;

}

#content{

overflow: auto;

margin: 15px;

padding: 0;

}

#content_left{

float: left;

width: 250px;

margin: 0 0 0 10px;

padding: 0;

}

#section{

margin: 0 0 15px 0;

padding: 0;

}

#section_1_top{

width: 176px;

height: 36px;

font-family: "黑体";

font-weight:bold ;

font-size: 14px;

color: #276b45;

background: url(../img/section_1_top_bg.jpg)no-repeat;

margin: 0px;

padding: 15px 0 0 70px;

}

#section_1_mid{

width: 217px;

background: url(../img/section_1_mid_bg.jpg)repeat-y;

margin: 0;

padding: 5px 15px;

}

#section_1_mid.myform{

margin: 0;

padding: 0;

}

.myform.frm_cont{

margin-bottom:8px ;

}

.myform.username input,.myform.password input{

width: 120px;

height: 18px;

padding: 2px 0px 2px 15px;

border: solid 1px #aacfe4;

}

.btns{

text-align: center;

}

#section_1_bottom{

width: 246px;

height: 17px;

background: url(../img/section_1_bottom_bg.jpg)no-repeat;

}

#section2{

margin: 0 0 15px 0;

padding: 0;

}

#section_2_top{

width: 176px;

height: 42px;

font-family: "黑体";

font-weight: bold;

font-size: 14px;

color: #276b45;

background: url(../img/section_2_top_bg.jpg)no-repeat;

margin: 0;

padding: 15px 0 0 70px;

}

#section_2_mid{

width: 246px;

background: url(../img/section_2_mid_bg.jpg)repeat-y;

margin: 0;

padding: 5px 0;

}

#section_2_mid ul{

list-style: none;

margin: 0 20px;

padding: 0;

}

#section_2_mid li{

border-bottom: 1px dotted #fff;

margin: 0;

padding: 5px;

}

#section_2_mid li a{

color: #fff;

text-decoration: none;

}

#section_2_mid li a:hover{

color: #363;

text-decoration: none;

}

#section_2_bottom{

width: 246px;

height: 18px;

background: url(../img/section_2_bottom_bg.jpg)no-repeat;

}

#content_right{

float: right;

width: 580px;

padding: 10px;

}

.post{

padding: 5px;

}

.post h1{

font-family: tahoma;

font-size: 18px;

color: #588970;

margin: 0 0 15px 0;

padding: 0;

}

.post p{

font-family: arial;

font-size: 12px;

color: #46574d;

text-align: justify;

margin: 0 0 15px 0;

padding: 0;

}

.post img{

margin: 0 0 0 25px;

padding: 0;

border: 1px solid #333;

}

#footer{

font-size: 12px;

color: #7bdaae;

text-align: center;

}

最终的效果图如下:

图2.2效果图

结语

这里需要注意的就是虽然你可以在你的HTML中使用特殊的字体,但是你不可能预测访问者在他们的计算机上将看到什么。在你的计算机里看起来相当好的页面,在另一个不同的平台上看起来可能非常糟糕。一些网站设计员喜欢使用来定义特性,这虽然允许你使用特殊的字体,但是仍需要一些变通的方法,以免你所选择的字体在访问者的计算机上不能显示。所以在设计网页时一定要考虑浏览器的兼容性问题。

END

实习编辑 | 王楠岚

责 编 | 刘 连

where2go 团队

微信号:算法与编程之美

相关作品

刀剑乱舞-ONLINE- 6-8图练级捞刀攻略
365在线体育

刀剑乱舞-ONLINE- 6-8图练级捞刀攻略

📅 10-11 👁️ 1131
天刀ol1-100级快速升级攻略
体育平台送365彩金

天刀ol1-100级快速升级攻略

📅 07-26 👁️ 7283
速卖通开店需要多少钱(详细费用明细)
体育平台送365彩金

速卖通开店需要多少钱(详细费用明细)

📅 08-01 👁️ 7329