css - 位置相对被阻止
问题描述
尝试使用 position:relative 将我的徽标移动到页面的左侧。但是,当我将它移动 20px 时,它不会移动,但是当我将它移动到底部 300px 时,它就会消失。
这是我的代码目前的样子:
.container-header {
justify-content: flex-end;
display: flex;
padding-bottom: 20px;
}
nav{
flex-wrap: nowrap;
margin-top: 20px;
}
nav a{
text-decoration: none;
box-sizing: border-box;
align-items: flex-end;
}
a{
box-sizing: border-box;
margin-bottom: 40px;
color: black;
margin: 20px;
}
img {
position: relative;
left: 40px;
}
关于为什么它不起作用的任何建议?
解决方案
使用 "margin-left" 代替 "left" :
img{
position: relative;
margin-left: 40px
}
我建议你在你的 img 周围制作一个“div”,以便更好地控制位置,希望它会有所帮助
推荐阅读
- javascript - Why does this work? Shouldn't the let reset the variable?
- java - 从矩阵的一点移动到零的位置
- matlab - 读取 Matlab 数字文件并将其打印出来
- sql - How to retrieve sentence data in chronological order?
- visual-studio-code - How do I run integration tests for a vscode extension that depends on other extensions
- vue.js - How to select a v-list-group child in vuetify?
- amazon-web-services - Jenkins behind a network load balancer AWS
- django - Crypting/decrypting user passwords used for basic auth in Django
- javascript - Javascript display == "none" 没有实际显示
- angular - Angular 拖放可以与启用分页和排序的 mat-table 一起使用吗?