2011-02-24 4 views
2

이미지 버튼에 imagebutton을 사용할 수 있다는 것을 알고 있습니다. 하지만 다운로드 한 이미지 수를 줄이기 위해 CSS 스프라이트를 사용하고 싶습니다. 그래서 나는 CSS 클래스를 통해 이미지에 일반 버튼을 할당하고 싶다. 그러나 그것은 작동하지 않는 것 같습니다. 여기 CSS 클래스를 통해 ASP.net 버튼 이미지 지정

내가

enter image description here

버튼 코드 여기

<asp:Button ID="btn1" CssClass="filter-tr" runat="server" /> 
<br /> 
<br /> 
<br /> 
<asp:Button ID="Button2" CssClass="filter-en" runat="server" /> 
<br /> 
<br /> 
<br /> 
<asp:Button ID="Button3" CssClass="flying" runat="server" /> 
<br /> 
<br /> 
<br /> 
<asp:Button ID="Button1" CssClass="fire" runat="server" /> 

CSS 클래스 코드

.filter-tr, .filter-en, .flying, .fire 
{ display: block; background: url('images/image1.png') no-repeat; } 

filter-tr { background-position: -0px -0px; width: 60px; height: 25px; } 
filter-en { background-position: -0px -25px; width: 60px; height: 25px; } 
flying { background-position: -0px -50px; width: 44px; height: 16px; } 
fire { background-position: -0px -66px; width: 44px; height: 16px; } 

을 시도 코드와 이미지 그러나이 방법은이

를 작동그게 내가 제공 할 수있는 모든 도움의 자세한 내용은없이

.filter-tr, .filter-en, .flying, .fire 
{ display: block; background: url('/images/image1.png') no-repeat; } 

: 내가 할 것

.filter-tr { display: block; background: url('images/image1.png') no-repeat; background-position: -0px -0px; width: 60px; height: 25px; border-width:0px; } 
+0

어디 작동하고 이미지가 위치한 폴더 : 클래스 이름은 모두 그들의 앞에 .이 필요? – nickmoriarty

+0

어떤 방식으로 작동하지 않습니까? – StriplingWarrior

+0

이미지 URL에 문제가 없거나 CSS를 포함 시키려고했습니다. 또한 첫 번째 질문 – MonsterMMORPG

답변

0

이 디렉토리 구조에

.filter-tr 
    { 
     display: block; 
     background: url('images/image1.png') no-repeat; 
     background-position: -0px -0px; 
     width: 60px; 
     height: 25px; 
    } 
    .filter-en 
    { 
     display: block; 
     background: url('images/image1.png') no-repeat; 
     background-position: -0px -25px; 
     width: 60px; 
     height: 25px; 
    } 
    .flying 
    { 
     display: block; 
     background: url('images/image1.png') no-repeat; 
     background-position: -0px -50px; 
     width: 44px; 
     height: 16px; 
    } 
    .fire 
    { 
     display: block; 
     background: url('images/image1.png') no-repeat; 
     background-position: -0px -66px; 
     width: 44px; 
     height: 16px; 
    } 
3

첫 번째 일은 절대 위치를 사용하는 배경 URL을 설정합니다.

편집 이전에 발견 했어야합니다. CSS를하다

.filter-tr { background-position: -0px -0px; width: 60px; height: 25px; } 
.filter-en { background-position: -0px -25px; width: 60px; height: 25px; } 
.flying { background-position: -0px -50px; width: 44px; height: 16px; } 
.fire { background-position: -0px -66px; width: 44px; height: 16px; } 
+0

이미지 URL이 문제가 없거나 CSS를 포함 시도 했어요. 또한 첫 번째 질문을 업데이트했습니다. – MonsterMMORPG

+0

@PokemonCraft : 내 업데이트 참조. – StriplingWarrior

관련 문제