2013-07-13 5 views
-1

저는 CSS가 처음이에요. 제 첫 번째 버튼입니다. 버튼에 텍스트를 넣는 데 문제가 있습니다. 글쎄, 그것은 버튼에 있지만 오른쪽 정렬되지 않습니다. 이 문제를 해결하는 방법을 모르겠지만 여기에 내 코드가 있습니다텍스트가 DIV에 들어 가지 않습니다

 body { 
    font-family: 'Open Sans', sans-serif; 
    background-color: #DB1F1F; 
    } 

    .navbar-menu { 
    margin: auto; 
    height: 100px; 
    width: 95px; 
    background-color: green; 
    padding: 10px 40px; 
    font-size: 25px; 
} 

    .navbar-menu:hover { 
    opacity: 0.5; 
} 

나는 그게 뭐가 잘못되어 누군가 도와 줄 수 있습니까?

오와 : HTML

<!DOCTYPE html> 
<html> 
<head> 
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> 
    <link type="text/css" rel="stylesheet" href="stylesheet.css" /> 
    <title>Button</title> 
    </head> 
<body> 
    <center> 
    <div class="navbar-menu">HTML/CSS</div> 
    </center> 
</body> 
</html> 
+0

당신은 우리가 HTML로하고있는 일의 예를 들려 줄 수 있습니까? – Enigmadan

+0

JS 피들을 게시하십시오. –

+0

http://jsfiddle.net/PkDKA/ –

답변

0

을 시도하십시오, 당신은 사용할 수 있습니다

//use for any element type 
text-align: center; 

//use only for inline element types e.g. span 
vertical-align: middle; 

//use for any block element type e.g. div 
//(replace 90 with height of block element) 
line-height: 90px; 
0

당신이 당신의 버튼 요소 (div의, 스팬, LIS)로 사용하는 작업에 따라이 코드

<!DOCTYPE html> 
<html> 
<head> 
<style type="text/css"> 
body { 
    font-family: 'Open Sans', sans-serif; 
    background-color: #DB1F1F; 
} 
.navbar-menu { 
background-color: green; 
    font-size: 25px; 
    height: 100px; 
    margin: 0 auto; 
    padding: 10px 43px; 
    width: 150px; 
} 
.navbar-menu:hover { 
    opacity: 0.5; 
} 
</style> 
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> 
<link type="text/css" rel="stylesheet" href="stylesheet.css" /> 
<title>Button</title> 
</head> 
<body> 
<div class="navbar-menu"><center> 
HTML/CSS 
</center></div> 
</body> 
</html> 
+0

왼쪽으로 정렬합니다. 텍스트는 버튼 중심에 있어야합니다. –

+0

이제는 효과가 있었지만 이제는 오른쪽으로 떠있었습니다. –

+0

지금 확인하십시오. – Ravi

관련 문제