我正在尝试使用css放置圆形图像,但事实证明它周围有一些透明空间/填充! 这是图片:
我尝试了padding: 0;
和margin: 0;
,但是它不起作用!这个空间弄乱了其他所有元素的布局和位置!
这是html(内部标签):
<body>
<div class="container">
<DIV class="navbar">
<div class="logo">
<img src="images/logo.png">
</div>
<nav>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Library</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<div class="user">
<p>"User's name"</p>
<img src="images/girl.png">
</div>
</DIV>
</div>
</body>
这是完整的CSS:
*{
margin: 0;
padding: 0;
font-family: sans-serif;
}
.container{
width: 100%;
height: 100vh;
background-image: url(images/background.jpg);
background-position: center;
background-size: cover;
position: relative;
padding-top: 2em;
box-sizing: border-box;
}
.navbar{
width: 100%;
height: 60px;
display: flex;
align-items: center;
background: rgba(29,33,61,0.5);
padding: 0 60px;
box-sizing: border-box;
}
.logo{
width: 155px;
}
.logo img{
width: 2.2em;
position: relative;
z-index: 10;
cursor: pointer;
}
nav{
display: flex;
flex: 1;
}
nav ul li{
list-style: none;
display: inline-block;
margin-right: 60px;
}
nav ul li a{
text-decoration: none;
color: #fff;
font-size: 14px;
}
.user{
display: flex;
align-items: center;
color: #fff;
font-size: 14px;
}
.user img{
width: 270px;
cursor: pointer;
padding: 0;
margin: 0;
position: relative;
top: 10px;
left: 50px;
}
如何处理此类情况?还有更好的选择吗?