资讯专栏INFORMATION COLUMN

【代码笔记】Web-CSS-CSS Positioning

番茄西红柿 / 2876人阅读

摘要:因为图像元素设置了属性值为所以它会显示在文字之后。参考资料菜鸟教程

一,效果图。

 

 

 

二,代码。

 

DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>CSS Positioningtitle>
    <style>
    p.pos_fixed {
        position: fixed;
        top: 30px;
        right: 5px;
    }
    
    h2.pos_left {
        position: relative;
        left: -20px;
    }
    
    h2.pos_right {
        position: relative;
        left: 20px;
    }
    
    h2.pos_top {
        position: relative;
        top: -50px;
    }
    
    h2.absolute {
        position: absolute;
        left: 100px;
        top: 150px;
    }
    
    img {
        position: absolute;
        left: 0px;
        top: 0px;
        z-index: -1;
    }
    style>
head>

<body>
    <p class="pos_fixed">Some more textp>
    <p><b>Note:b> IE7 and IE8 supports the fixed value only if a !DOCTYPE is specified.p>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some textp>
    <p>Some text

Some text

Some text

Some text

Some text

Some text

This is a heading with no position

This heading is moved left according to its normal position

This heading is moved right according to its normal position

Relative positioning moves an element RELATIVE to its original position.

The style "left:-20px" subtracts 20 pixels from the elements original left position.

The style "left:20px" adds 20 pixels to the elements original left position.

This is a heading with no position

This heading is moved upwards according to its normal position

Note: Even if the content of the relatively positioned element is moved, the reserved space for the element is still preserved in the normal flow.

This is a heading with an absolute position

With absolute positioning, an element can be placed anywhere on a page. The heading below is placed 100px from the left of the page and 150px from the top of the page.

This is a heading

因为图像元素设置了 z-index 属性值为 -1, 所以它会显示在文字之后。

 

参考资料:《菜鸟教程》

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/1246.html

相关文章

  • 代码笔记Web-CSS-CSS 教程

    一,效果图。 二,代码。 DOCTYPE html> CSS 教程 body { background-color: #d0e4fe; } h1 { color: range; text-align: center; } p { fon...

    endless_road 评论0 收藏0
  • 代码笔记Web-CSS-CSS 语法

    一,效果图。 二,代码。 DOCTYPE html> CSS 语法 p { color: red; text-align: center; } Hello world! this paragraph is styled with css   参考资料:《菜鸟教程》

    zhangwang 评论0 收藏0
  • 代码笔记Web-CSS-CSS id和Class选择器

    一,效果图。 二,代码。 DOCTYPE html> CSS id和class选择器 #para1 { text-align: center; color: red; } .center { text-align: center; } p.center...

    Pluser 评论0 收藏0
  • 代码笔记Web-CSS-CSS background背景

    摘要:实例改文本插入在元素中该段落有自己的背景颜色背景图片不重复,设置实例背景图片只显示一次,并与文本分开实例中还添加了属性用于让图片与文本间隔开参考资料菜鸟教程一,效果图。 二,代码。 DOCTYPE html> CSS backgrounds h1 { background-color: #6495ed; } ...

    番茄西红柿 评论0 收藏0
  • 代码笔记Web-CSS-CSS Text(文本)

    摘要:文本加上上划线全变成大写文本的第一行缩进加上下划线全变成小写加上下划线首字母大写去掉链接的下划线参考资料菜鸟教程一,效果图。   二,代码。     DOCTYPE html> CSS Test(文本) body { color: red } h1 { color: #00ff00; ...

    tain335 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<