行内元素进行绝对定位后会变成块级元素·

position:absolute;

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/* *{
padding: 0;
margin: 0;
} */
span{
position: absolute;

/* 一定要写四个位置,否则无法居中显示 */
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 400px;
height: 400px;
background: rgba(255, 0, 255, .6);
margin: auto;
}
</style>
</head>
<body>
<span>行内元素进行绝对定位后会变成块级元素</span>
<a href="#">行内元素进行绝对定位后会变成块级元素</a>
<a href="#">样式,先写width,height,position,top,right,bottom,left确定位置</a>
<a href="#">再写不影响布局的color,background,font-size,font-family等等</a>
</body>
</html>

==============================================

行内元素进行固定定位后会变成块级元素·

position:fixed;

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/* *{
padding: 0;
margin: 0;
} */
span{
position: fixed;

/* 一定要写四个位置,否则无法居中显示 */
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 400px;
height: 400px;
background: rgba(255, 0, 255, .6);
margin: auto;
}
</style>
</head>
<body>
<span>行内元素进行绝对定位后会变成块级元素</span>
<a href="#">行内元素进行绝对定位后会变成块级元素</a>
<a href="#">样式,先写width,height,position,top,right,bottom,left确定位置</a>
<a href="#">再写不影响布局的color,background,font-size,font-family等等</a>
</body>
</html>

相关文章:

  • 2022-03-07
  • 2021-09-26
  • 2021-12-26
  • 2022-02-07
  • 2021-09-24
  • 2021-11-28
  • 2022-02-07
  • 2021-10-29
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2022-02-13
  • 2021-12-28
相关资源
相似解决方案