当前位置:网站首页>Positioning and decoration style
Positioning and decoration style
2022-04-23 08:05:00 【GuTaiWEI】
location
Positioning mode
Property value | Reference system | characteristic | remarks |
---|---|---|---|
static | position The default value of | nothing | Invalid set offset value |
relative ( Relative positioning ) | Oneself | Do not delist | It is usually used in the structure of son Jue father phase , The offset value is not needed at this time |
absolute ( Absolute positioning ) | Locate the nearest outer element or document ( Browser window ) | Complete de labeling | Usually used with offset values |
fixed ( Fixed position ) | Browser viewable window | Complete de labeling | Usually used with offset values , Don't follow the scroll bar , Width and height should be set |
sticky ( Viscous positioning ) | Itself and browser window | Partial off standard | A scroll bar appears on the page , At least one offset value needs to be set |
Be careful :
- Element is not set left、top、right、bottom When is invalid
- left and top The priority ratio right and bottom Be taller
- Positioning elements will become similar Inline block element Characteristics , Width and height can be set , Don't monopolize a line
- position Valid for all elements
- The level of positioning elements is the same , There is lamination , The rear positioning element will cover the front positioning element , Use Fixed position Need to pay attention to
Offset value
type | Value | remarks |
---|---|---|
left | px Or percentage | Usually and right Just one , When used at the same time left first |
top | px Or percentage | Usually and bottom Only one of them , When used at the same time top first |
right | px Or percentage | |
bottom | px Or percentage |
z-indx Display hierarchy
Format : z-index:
Integers ;
Be careful :
- The larger the value , The higher the display order , z-index The default value of is 0, You can set negative
- z-index Only with positioning can it take effect , By default , Positioned box Later generations live in
Application of positioning ( Vertical center )
/* The absolute positioning element is horizontally and vertically centered */
.box{
position: absolute;
/* Ideas 1:left:50% top:50% then margin-left:- Half the width of itself ; margin-top:- Half its height ; */
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -100px;
/* Ideas 2: left:0;top:0;right:0;bottom:0;margin:auto; */
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 100px;
height: 100px;
background-color: pink;
/* Ideas 3 left:50% top:50% transform:translate(-50%,-50%) */
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Decorative style
vertical-align Set vertical alignment
Application scenarios : Applied to solve vertical problems Alignment issues for
Effective range : Valid only for inline elements or inline block elements
Property value :
- middle( Vertical center )
- top ( Align vertically up )
- bottom( Align vertically down )
- xxxpx( be based on baseline)
- Default Baseline alignment
Typical scenario : solve img No height is set outside div Bottom and img There is a gap at the bottom ( The reasons causing : Baseline alignment )
<style>
Solution 1:
img {
display:block;
}
Solution 2:
img {
vertical-align:middle;
}
Solution 3:
div {
font-size:0;
}
</style>
<div class="father"><img src="./images/1.jpg" alt=""></div>
cursor Set the mouse cursor
Common values :
default
arrowpointer
Little handstext
editmove
Crossnot-allowed
prohibit
border-radius Set rounded border
Setting mode :
/* Set four fillet radii Are all 10px*/
border-radius:10px;
/* Set four fillet radii All are wide 50%/ high 50% When the box is square, it can realize circle When it is rectangular, realize ellipse */
border-radius:50%;
/* Set separately Top left The upper right The lower right The lower left ( Clockwise ) Four fillet radii by 10px 20px 30px 40px*/
border-radius: 10px 20px 30px 40px;
/* Set the fillet radius of the upper left corner separately by 10px*/
border-top-left-radius:20px;
Hidden elements
Show hidden :
-
overflow:hidden
: Overflow hiddenoverflow:auto
: Scroll bar appears when overflowoverflow:scroll
: There's always a scroll baroverflow:visible
: Overflow display ( Default state )
-
opacity
:1 Completely opaque 0 Completely transparent 0.5 translucent
Implicitly hide :
-
display:none
: Pure Hidden , Does not occupy a space -
visibility:hidden
: Take up space
border-collapse Set up Border merge
table {border-collapse:collapse;/* Set border merging to realize thin line border */}
border Realize the small triangle
<style>
.box {
width: 0;
height: 0;
margin:50px auto;
border:20px solid;
/* Realize the isosceles right triangle with the arrow to the right */
border-color: transparent transparent transparent pink;
}
.box1 {
width: 0;
height: 0;
margin:50px auto;
border-style:solid;
border-width:0 150px 50px 150px;
/* Realize that the two right angle sides of the arrow to the right are 50 150 Right triangle of */
border-color:transparent transparent transparent red;
}
</style>
<div class="box"></div>
<div class="box1"></div>
版权声明
本文为[GuTaiWEI]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624538807.html
边栏推荐
猜你喜欢
Cloud computing skills competition -- the first part of openstack private cloud environment
Construction of middleman environment mitmproxy
国基北盛-openstack-容器云-环境搭建
Export all SVG files in the specified path into pictures in PNG format (thumbnail or original size)
Research on software security based on NLP (I)
Ribbon start process
内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
How does Apache Hudi accelerate traditional batch mode?
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
随机推荐
攻防世界MISC刷题1-50
TA notes of Zhuang understand (zero) < bedding and learning methods >
Ribbon start process
Research on software security based on NLP (I)
Go语学习笔记 - 语言接口 | 从零开始Go语言
KCD_ EXCEL_ OLE_ TO_ INT_ Convert reports an error sy subrc = 2
Intranet penetration series: icmpsh of Intranet tunnel
Alibaba sentinel学习QA
Research on system and software security (5)
在线YAML转XML工具
Attack and defense world misc questions 1-50
Flutter之Provider共享数据的两种方式
GUI,CLI与Unix哲学
Essays (updated from time to time)
What's new in. Net 5 NET 5
Principle of sentinel integrating Nacos to update data dynamically
爬虫学习笔记,学习爬虫,看本篇就够了
一些关于网络安全的好教程或笔记的链接,记录一下
RAID0和RAID5的创建和模拟RAID5工作原理
RGB color to hex and unit conversion