分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

CSS定位

发布时间:2023-09-06 01:22责任编辑:彭小芳关键词:CSS

CSS定位

  position既是一个模块也是一个属性。

  

position-static

  也叫静态定位/常规定位/自然定位——定位中的一股清流-回归本真

  

作用

使元素定位于 常规/自然流 中

(块、行垂直排列下去、行内水平从左到右)

特点

(1)忽略top、bottom、left、right或者z-index声明

(2)两个相邻的元素如果都设置了外边距,那么最终外边距=两者外边距中最大的

(3)具有固定width和height值的元素,如果把左右外边距都设置为auto,则左右外边距会

自动扩大占满剩余宽度,造成的效果就是这个块水平居中

<!DOCTYPE html><html><head> ???<meta charset="utf-8"> ???<title>position-static</title> ???<link rel="stylesheet" type="text/css" href="reset.css"> ???<style type> ???????.block{ ???????????position: static; ???????????width: 50px; ???????????height: 50px; ???????????line-height: 50px; ???????????text-align: center; ???????????border:2px solid blue; ???????????box-sizing: border-box; ???????} ???????.block:nth-child(1){ ???????????border:2px solid green; ???????????margin: 10px; ???????} ???????.block:nth-child(2){ ???????????border:2px solid red; ???????????margin: 30px; ???????} ???????.block:nth-child(3){ ???????????border:2px solid green; ???????????margin-left: auto; ???????????margin-right: auto; ???????} ???</style></head><body> ???<div class="block"> ???????A ???</div> ???<div class="block"> ???????B ???</div> ???<div class="block"> ???????C ???</div> ???<div class="block"> ???????D ???</div></body></html>

  position-relative

CSS定位

原文地址:http://www.cnblogs.com/jhl123/p/7773816.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved