แก้ css ให้ไอคอน และ text อยู่ตรงกลาง ทำอย่างไรครับ (มีรูป,ไฟล์ ประกอบ)

เริ่มโดย Fallen, 26 ตุลาคม 2013, 10:06:15

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Fallen

แก้มานานละ ลองปรับดู พอทำให้ icon อยู่ตรงกลางได้ text ก็ขยับอีก จากตรงกลางเป็นไม่กลางอ่ะ

:wanwan017:

http://gnss-rtk.com/menu/




code html
<!DOCTYPE html>
<html lang="en" >
   <head>
       <meta charset="utf-8" />
       <title>XX</title>
       <link href="css/menu.css" rel="stylesheet" type="text/css" />
   </head>
   <body bgcolor="#000000">

       <ul id="nav">
           <li><a href="#">EMAIL</a>
               <ul>
<li><a target="_blank" href="http://mail.google.com">g-mail</a></li>
                   <li><a target="_blank" href="http://mail.bing.com">hot-mail</a></li>
                   <li><a target="_blank" href="http://mail.yahoo.com">yahoo-mail</a></li>
               </ul>
           </li>
           <li><a target="_blank" href="http://google.co.th/"><img border="0" src="images/y.png" width="32" height="32"></a>
           <li><a href="#"><img border="0" src="images/y.png" width="32" height="32"></a>
</li>
           <li><a href="http://www.mail.yahoo.com/">Link ต่างๆ</a>

</li>

       </ul>
   </body>
</html>


css
#nav,#nav ul {
   list-style: none outside none;
   margin: 0;
   padding: 0;
}
#nav {
   font-family: "Lucida Sans Unicode",Verdana,Arial,sans-serif;
   font-size: 13px;
   height: 36px;
   list-style: none outside none;
   margin: 0px auto;
   width: 850px;

   /* gradient */
   background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
   background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
   background-color: #5f5f5f;
}
#nav li {
   border-bottom: 1px solid #FFFF00;
   border-left: 1px solid #FF0000;
   border-right: 1px solid #FFFF00;
   border-top: 1px solid #FF0000;
   display: block;
   float: left;
   height: 34px;
   position: relative;
   width: 105px;
}
#nav > li:first-child {
   border-left: 0 none;
   margin-left: 5px;
}
#nav ul {
   left: -9999px;
   position: absolute;
   top: -9999px;
   z-index: 2;
}
#nav ul li {
   background: none repeat scroll 0 0 #838383;
   box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
   width: 100%;
}

#nav li a img {
 vertical-align: middle;
}

#nav li a {
   color: #FFFFFF;
   display: block;
   line-height: 34px;
   outline: medium none;
   text-align: center;
   text-decoration: none;
   
}

/* keyframes #animation */
@-webkit-keyframes animation {
   0% {
       -webkit-transform: scale(1);
   }
   40% {
       -webkit-transform: scale(1.2);
   }
   100% {
       -webkit-transform: scale(1.1);
   }
}
@-moz-keyframes animation {
   0% {
       -moz-transform: scale(1);
   }
   30% {
       -moz-transform: scale(1.2);
   }
   100% {
       -moz-transform: scale(1.1);
   }
}
#nav li > a:hover {
   /* CSS3 animation */
   -webkit-animation-name: animation;
   -webkit-animation-duration: 0.3s;
   -webkit-animation-timing-function: linear;
   -webkit-animation-iteration-count: 1;
   -webkit-animation-direction: normal;
   -webkit-animation-delay: 0;
   -webkit-animation-play-state: running;
   -webkit-animation-fill-mode: forwards;

   -moz-animation-name: animation;
   -moz-animation-duration: 0.3s;
   -moz-animation-timing-function: linear;
   -moz-animation-iteration-count: 1;
   -moz-animation-direction: normal;
   -moz-animation-delay: 0;
   -moz-animation-play-state: running;
   -moz-animation-fill-mode: forwards;
}
#nav li:hover ul {
   left: 0;
   top: 34px;
   width: 150px;
}


:wanwan017:
[direct=https://www.cymiz.com/]ประกันภัย[/direct]
[direct=https://www.cymiz.com/promotion/]ประกันรถยนต์ พรบ มอเตอร์ไซต์ ราคาสมาชิก[/direct]
[direct=http://cymiz.com/].[direct=http://vir9.com].[/direct][/direct]

aofiezzangz

คือยังไม่ค่อยเข้าใจคำถาม  :wanwan023:


ประมาณว่า อยู่ตรงกลาง ไม่ชิดซ้าย-ขวา แล้ว ไม่ชิดบนล่างด้วยหรือเปล่า

iC1assicTh

งงอ่ะ --* แต่ลองมองดูก็คงมีอยู่ปัญหาเดียวปะ ที่ icon มันลงมาทับขอบ bar ล่าง

ลองดูตรง
#nav li a img

เอานี่ออกดูครับ
vertical-align: middle;

ไม่รู้ถูกจุดปะนะ --*


[direct=http://www.fittechrayong.com/]ฟิตเนส ระยอง[/direct] : [direct=http://elec.fc2ry.com/]อะไหล่อิเล็กทรอนิกส์[/direct] : [direct=http://www.btn-electronics.com/]อะไหล่ตู้เชื่อม[/direct] : [direct=http://mpfix.fc2ry.com/]ซ่อมเครื่องใช้ไฟฟ้า ระยอง[/direct]

Surakrai


Fallen

อ้างถึงจาก: Surakrai ใน 26 ตุลาคม 2013, 10:19:19
เพิ่ม margin-top: -3px; ใน

#nav li a img {
   vertical-align: middle;
   margin-top: -3px;
}



+ สุดยอดมากครับ Surakrai

:'(

(ผมค้นหาในGoogle ไม่ต่ำกว่า สิบ ชม ลองตั้งนานไม่ได้สักที ห่างกันแค่ 3px หายไป 10 ชั่วโมงเบยยย)

อ้างถึงจาก: aofiezzangz ใน 26 ตุลาคม 2013, 10:15:54
คือยังไม่ค่อยเข้าใจคำถาม  :wanwan023:


ประมาณว่า อยู่ตรงกลาง ไม่ชิดซ้าย-ขวา แล้ว ไม่ชิดบนล่างด้วยหรือเปล่า

เห็นไอคอนไม๊ครับ มันไม่อยู่ตรงกลาง ขอบบนเเละล่าง ไปทับเส้นเหลืองครับ

อ้างถึงจาก: iC1assicTh ใน 26 ตุลาคม 2013, 10:18:18
งงอ่ะ --* แต่ลองมองดูก็คงมีอยู่ปัญหาเดียวปะ ที่ icon มันลงมาทับขอบ bar ล่าง

ลองดูตรง
#nav li a img

เอานี่ออกดูครับ
vertical-align: middle;

ไม่รู้ถูกจุดปะนะ --*

แก้เเล้วไอคอน มันจะเขยิบสูงไปอีกครับ
[direct=https://www.cymiz.com/]ประกันภัย[/direct]
[direct=https://www.cymiz.com/promotion/]ประกันรถยนต์ พรบ มอเตอร์ไซต์ ราคาสมาชิก[/direct]
[direct=http://cymiz.com/].[direct=http://vir9.com].[/direct][/direct]

aliztotle

ขอตอบแบบมักง่ายนะครับ ... ผมตั้งค่า text-align: center; paddding; ....; ตั้งค่าตามความเหมาะสมครับ หรืออีกวิธิีที่ทำ ก็กำหนด line-height: ....em; ตามด้วย ตั้วค่า text-align: center;  :wanwan017:
เติ้ล เว็บดีไซน์รับทำเว็บไซต์,  รับดูแลเว็บไซต์, งานกราฟฟิก=>> www.aliztotle.com