div{ width: 600px; height: 300px; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); border-whidth: 8px; border-style: solid dashed; border-color: #ccc #444; }为什么有警告
时间: 2024-03-22 12:42:23 浏览: 73
这段代码中的 "border-whidth" 应该改为 "border-width",因为单词拼写错误导致了警告。正确的代码应该是:
```
div {
width: 600px;
height: 300px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border-width: 8px;
border-style: solid dashed;
border-color: #ccc #444;
}
```
相关问题
如何实现底部对齐,目前CSS代码父类:/*设置容器位置,margin上右下左*/ #container{ width:500px; background-color: #fff; height:550px; border-radius: 10px; box-shadow: 0 0 0 5px deepskyblue,0 0 0 10px orangered,0 0 0 15px deepskyblue; position: relative; left: 50%; top: 50%; transform: translate(-50%, -50%); },子类:/*设置div中的文字样式*/ .last{ text-align: center; font-size:15px; margin-top:18%; position:absolute; left:28%; }
要实现底部对齐,可以将父类的position属性改为fixed,并将bottom属性设置为0。修改后的代码如下:
#container{
width:500px;
background-color: #fff;
height:550px;
border-radius: 10px;
box-shadow: 0 0 0 5px deepskyblue,0 0 0 10px orangered,0 0 0 15px deepskyblue;
position: fixed;
left: 50%;
bottom: 0;
transform: translate(-50%, 0);
}
子类的样式可以不变。这样就可以实现底部对齐了。
如何实现底部对齐,目前CSS代码父类:/设置容器位置,margin上右下左/ #container{ width:500px; background-color: #fff; height:550px; border-radius: 10px; box-shadow: 0 0 0 5px deepskyblue,0 0 0 10px orangered,0 0 0 15px deepskyblue; position: relative; left: 50%; top: 50%; transform: translate(-50%, -50%); },子类:/设置div中的文字样式/ .last{ text-align: center; font-size:15px; margin-top:18%; position:absolute; left:28%; },不能修改父类因为有其他子类应用
如果不能修改父类,可以将子类的position属性改为fixed,并将bottom属性设置为0。修改后的代码如下:
.last{
text-align: center;
font-size:15px;
margin-top:18%;
position: fixed;
left:28%;
bottom: 0;
}
这样就可以实现底部对齐了。请注意,如果父类的高度不足以容纳所有子类,可能会出现遮挡的情况。如果出现这种情况,可以考虑调整父类的高度或将子类分组放置。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
请帮助我把每一行代码写上注释:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>导航栏</title> <style> *{ margin: 0; padding: 0; box-sizing:border-box; font-family:"Poppins",sans-serif; } .cantainer{ width:100%; height:100vh; background-color: #e092a1; background-size: 100% 100%; display:flex; align-items: center; justify-content: center; } nav{ background: #fff; border-radius: 50px; padding: 10px; box-shadow: 0 25px 20ox -20px rgba(0 , 0, 0, 0.4); } nav ul li{ list-style: none; display: inline-block; padding: 13px 35px; margin: 10px; font-size: 18px; font-weight: 500; color: #777; cursor: pointer; position: relative; z-index: 2; transform: color 0.5s; } nav ul li::after{ content:''; background:#f44566; width: 100%; height: 100%; border-radius: 30px; position: absolute; top: 100%; left: 50%; transform: translate(-50% ,-50%); z-index: -1; opacity: 0; transition:top 0.5s,opacity 0.5s; } nav ul li:hover{ color: #fff; } nav ul li:hover:after{ top:50%; opacity: 1; } a{ text-decoration: none; color: #706363; text-decoration: none; } .enen{ width: 10%; height: 10%; } </style> </head> <body> 1 2 3 4 5 6 </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)