[英]Aligning nav bar items, logo and image
So I have a navbar that currently looks like this:所以我有一个目前看起来像这样的导航栏:
I'm trying to change the position of the "info" icons so that they're slightly more down than now.我正在尝试更改“信息”图标的位置,使它们比现在稍微向下。 Ideally something like 3-5 px more down.
理想情况下,像向下 3-5 像素。
If I try to add like "margin-top: 5px" also the written come down with it, not solving my issues.如果我尝试添加像“margin-top: 5px”这样的文字,也会随之写下来,而不是解决我的问题。
This is my code:这是我的代码:
React Render:反应渲染:
<div className="toolbar">
<div className = "menu">
<img className = "logo" src={logo} alt="logo"onClick={refreshPage}/>
<a className = "buttons" id = "firstOne" onClick={() => this.handleClick("bubbleSort")}> Bubble Sort</a>
<info className = "info" alt="info"/>
<a className = "buttons" onClick={() => this.handleClick("selectionSort")}> Selection Sort </a>
<info className = "info" alt="info"/>
<a className = "buttons" onClick={() => this.handleClick("insertionSort")}> Insertion Sort </a>
<info className = "info" alt="info"/>
<a className = "buttons" onClick={() => this.handleClick("quickSort")}> Quick Sort </a>
<info className = "info" alt="info"/>
<a className = "buttons" onClick={() => this.handleClick("mergeSort")}> Merge Sort </a>
<info className = "info" alt="info"/>
</div>
</div>
CSS: CSS:
.toolbar {
height: 67px;
background-color: #303031;
display: flex;
align-items: center;
position: relative;
box-shadow: 0px 0px 40px -2px rgba(0,0,0,2);
z-index: 2;
position: fixed;
top: 0;
width: 100%;
}
.buttons{
/* text */
font-size: 16px;
line-height: 3.14286;
font-weight: 400;
letter-spacing: -.01em;
font-family: "SF Pro Text","Myriad Set Pro","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
color: #9a9a95;
/*position*/
margin-right: 5px;
}
#firstOne {
margin-left: 335px;
}
.info {
width: 20px;
height: 25px;
background: url("info.png");
margin-right: 100px;
display: inline-block;
}
.logo {
position: absolute;
top: 50%;
margin-top: -33px;
margin-left: 20px;
}
I know it's a long code and a confusing CSS.我知道这是一个很长的代码和一个令人困惑的 CSS。 I'm new to CSS and HTML coding I'm sorry if it's bad.
我是 CSS 和 HTML 编码的新手,如果它不好,我很抱歉。 I'd appreciate some help.
我很感激一些帮助。 Thanks a lot
非常感谢
Either use this:要么使用这个:
<div style="padding-top: 5px;"><info className = "info" alt="info"/></div>
Probable in react something like this:可能的反应是这样的:
<div style={{padding-top: "5px"}}><info className = "info" alt="info"/></div>
Or just give .info{margin-top:5px;}
或者只是给
.info{margin-top:5px;}
padding-top can help, but it will probably make the buttons higher. padding-top 可以提供帮助,但它可能会使按钮更高。 You can use
您可以使用
.info {
transform: translateY(3px)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.