2012-02-10 3 views
8
내가 정렬 된 목록 스타일을 시도하고

(NO 점, 반경 테두리와 회전 45 °)CSS : 목록에 의사 요소 이전의 내용을 스타일링

<div class="test"> 
    <ol> 
    <li><span>it's a test</span></li> 
    <li><span>and again</span></li> 
    </ol> 
</div> 

그리고 CSS를

.test ol { 
    counter-reset: li; 
    list-style-type: none; 
} 
.test ol > li { 
    position:relative; 
    list-style:none; 
} 
.test ol > li:before { 
    content:counter(li); 
    counter-increment:li; 

    position:absolute; 
    top:-2px; 
    left:-24px; 
    width:21px; 

    color:#E2202D; 
    font-weight:bold; 
    font-family:"Helvetica Neue", Arial, sans-serif; 
    text-align:center; 
    border: 1px dashed #E2202D; 
    -webkit-border-radius:6px; 
    border-radius:6px; 
    -webkit-transform: rotate(45deg); 
} 
내부의 수를 회전하지 않고 어떻게 국경을 회전 ...

그것은 나에게 that

을주고 그리고 이것은 내가 차단하고있어 여기에있다? CSS에서 의사 요소의 내용을 스타일링하는 방법은 무엇입니까?

조언 해 주셔서 감사합니다.

답변

7

테두리와 텍스트를 별도로 회전 할 방법이 없습니다. 대신 번호와 경계를 서로 다른 두 개의 의사 요소 인 :before:after으로 분할 할 수 있습니다.

참조 :http://jsbin.com/agotuj/54/edit

.test ol { 
    counter-reset: li; 
    list-style-type: none; 
} 
.test ol > li { 
    position: relative; 
    list-style: none; 
    margin-bottom: 20px; 
    padding-left: 5px; 
} 
.test ol > li:before, .test ol > li:after { 
    position: absolute; 
    top: -2px; 
    left: -24px; 
    width: 21px; 
    height: 21px; 
    line-height: 21px; 
    font-size: 16px; 
} 
.test ol > li:before { 
    content: counter(li); 
    counter-increment: li; 
    color: #E2202D; 
    font-weight: bold; 
    font-family: "Helvetica Neue", Arial, sans-serif; 
    text-align: center; 
} 
.test ol > li:after { 
    content: ''; 
    border: 1px dashed #E2202D; 
    border-radius: 6px; 
    -webkit-transform: rotate(45deg); 
     -moz-transform: rotate(45deg); 
     -ms-transform: rotate(45deg); 
     -o-transform: rotate(45deg); 
      transform: rotate(45deg); 
} 
+0

날은 몇 초에서 이길 :) 팁에 대한 – sandeep

+0

니스, 덕분에 많이! – barbuk

+0

제발, '변환'W3C 표준 구문을 잊지 마세요! WebKit 브라우저에서만 지원됩니다. IE9조차도'-ms-'로 지원합니다. –

-1
{"data":{"error":"HTTP Access is disabled. Requests must use SSL (HTTPS)."},"success":false,"status":400}