CSS编程练习和界面设计

2019-03-25  本文已影响0人  未央花语

1. 实验准备

2. 实验内容

实验一
实验二
效果展示.png
图片引用地址: http://img.mukewang.com/53edaa5a0001c86705000420.jpg

3.详细操作

实验一具体要求

基础代码:

<!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 http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <title>无标题文档</title>
  <style type="text/css">
/*在此定义相应的类选择器,并根据要求设置相关CSS属性*/
  </style>
 </head>
 <body>
  <div class="mainBox">//添加div标签,并设置属性
   <div class="leftBox"></div> &nbsp; //leftBox和rightBox需要嵌套在mainBox中
   <div class="rightBox"></div>
  </div>
 </body>
</html>
<style>
     .mainBox{
            width: 960px;
            height: 300px;
            background-color: #CFF;
       }
     .leftBox{
           width: 740px;
           height: 300px;
           background-color: #C9F;
           background-repeat: no-repeat;
           float: left;  //使leftBox向左浮动
    }
    .rightBox{
            width: 210px;
            height: 300px;
            background-color: #FCF;
            text-align: center;
            float: right;    //使rightBox向右浮动
        }
  </style>
实验二具体要求

在style标签内完以下样式定义:

基础代码:

<!doctype html>
<html>
 <head>
 <meta charset="utf-8">
 <title>无标题文档</title>
 <style>
/*在此定义相关样式*/
 </style>
 </head>
 <body>
  <div class="newsBox">
   <h1 class="newsTitle">慕课网获App Store强力推荐荣登四榜单</h1>
   <p class="newsInfo">发布人:Admin 发布时间:2014-08-01 浏览:5321次</p>
   <div class="newsContent">
    <p> 8月伊始,慕课网App……是IT学习的最佳选择。</p>
    <p> App Store力荐慕课网荣登四榜单</p>
    <p>App Store因公平著称,……推荐。</p>
    <p><img src=" http://img.mukewang.com/53edaa5a0001c86705000420.jpg" width="500" height="420" alt=""/></p>
    <p>事实上,……得到了用户的认可。</p>
   </div>
  </div>
 </body>
</html>
.newsBox{
            width: 800px;
        }
.newsTitle{
            text-align: center;
        }
.newsInfo{
           text-align: center;
            color:#8A8989;
        }
.newsContent p{
            text-indent: 2em;
            line-height: 25px;/* 行高25px  */
            font-family:Arial,Helvetica;
            /*em是相对单位,2em即现在一个字大小的两倍*/
        }
  .imgine{
            width: 800px;
            display: table-cell; /* 图片水平居中显示 */
            vertical-align: middle;
            text-align: center;
        }
.sTitle{
            font-weight: bold;
        }

注意:<p></p>之间的文字可以替换成自己想要的内容,图片也可以更换。

上一篇 下一篇

猜你喜欢

热点阅读