简体   繁体   English

图像大小和位置

[英]image size and position

I added an image on my navigation bar but this image position is not set. 我在导航栏上添加了一个图像,但未设置此图像位置。 So I try to set through margin. 所以我试着设定保证金。 When I add margin-right:20px then "events" title goes to the right side but I want to set position of image right side. 当我添加margin-right:20px然后“events”标题转到右侧但我想设置图像右侧的位置。

Image what I try: 想象一下我的尝试:

image 1 http://oi65.tinypic.com/jtqequ.jpg image 1 http://oi65.tinypic.com/jtqequ.jpg

Image what I want: 想象我想要的:

image 2 http://oi64.tinypic.com/33xc96v.jpg image 2 http://oi64.tinypic.com/33xc96v.jpg

 .lefttabs{ background-color:#1E1E1E; color:White; font-family:Calibri; font-weight:bold; font-size:medium; width: 187px; height: 100%; z-index:1;/* Stay on top */ padding-top: 60px; /* Place content 60px from the top */ transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */ } .lefttabs a { text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; font-size:medium; color:White; width: 133px; margin-left: 0px; } .lefttabs ul{ list-style:none; margin:0px 20px 0px 0px; border:1 px solid; border-color:Black; } .lefttabs li{ list-style:none; } .lefttabs li a { list-style:none; display:block; padding: 0px 0px 30px 0px; padding-left: 10px; padding-top: 10px; } .lefttabs a:hover,.offcanvas a:focus{ color: green; background-color:White; border-bottom-color:Red; color:#000!important; border:1px solid; } .imga{ margin-right:20px; } 
 <div class="lefttabs"> <ul> <li> <a href=""> <img class="imga" alt="" src="images/eve.bmp" border="0" />EVENTS</a> </li> </ul> </div> 

Without going trough all your CSS, this are the basics: 无需通过所有CSS,这是基础知识:

 .lefttabs{ background:#444; } .lefttabs ul{ list-style: none; margin:0; padding: 0; } .lefttabs a{ display: block; padding: 8px; text-decoration: none; color:#fff; line-height: 24px; /* 24px are icons so use same line height */ } .lefttabs a img{ margin:0 8px 0 0; vertical-align: top; /* needed */ } 
 <div class="lefttabs"> <ul> <li> <a href="#"><img class="imga" alt="icon" src="//placehold.it/24x24"/>EVENTS</a> </li> <li> <a href="#"><img class="imga" alt="icon" src="//placehold.it/24x24/f0f"/>STUFF</a> </li> </ul> </div> 

Here is fiddle with very small change : https://jsfiddle.net/9ns31Lu6/1 这里有一个非常小的改变: https//jsfiddle.net/9ns31Lu6/1

I've just added vertical-align: middle; 我刚添加了vertical-align: middle; to your .imga class. 到你的.imga课程。

And here is another https://jsfiddle.net/9ns31Lu6/3/ to match with somewhat your image. 这是另一个https://jsfiddle.net/9ns31Lu6/3/与你的图像匹配。

And here https://jsfiddle.net/9ns31Lu6/4/ it's for multiple menu items. 在这里https://jsfiddle.net/9ns31Lu6/4/这是多个菜单项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM