2012-02-10 13 views
8

Tôi đang cố gắng để tạo kiểu một danh sách có thứ tự (không có dấu chấm, một biên giới với bán kính và xoay 45 °)CSS: Tạo kiểu nội dung của yếu tố trước khi giả trên một danh sách

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

Và 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); 
} 

Nó cho tôi that

Và đây là ở đây tôi đang chặn ... Làm thế nào để xoay biên giới mà không cần xoay số bên trong? Làm thế nào để phong cách nội dung của một phần tử giả trong css?

Cảm ơn lời khuyên nào :)

Trả lời

7

Không có cách nào để xoay đường viền và văn bản riêng biệt. Thay vào đó, bạn có thể chia số và đường viền thành hai phần tử giả khác nhau, :before:after.

Xem: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

bạn đánh tôi từ vài giây :) – sandeep

+0

Nice, thanks a lot cho những lời khuyên! – barbuk

+0

XIN VUI LÒNG, đừng quên cú pháp tiêu chuẩn W3C cho 'biến đổi'! Không chỉ các trình duyệt WebKit hỗ trợ nó. Ngay cả IE9 cũng hỗ trợ nó với '-ms-'. –

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