Bạn chỉ cần phải là người ngồi sáng tạo:
HTML:
<div id="circle">
<div id="cover"></div>
<div id="innerCircle">
<div id="rect1"></div>
<div id="rect2"></div>
</div>
</div>
CSS:
#circle {
width: 140px;
height: 140px;
background: red;
-moz-border-radius: 70px;
-webkit-border-radius: 70px;
border-radius: 70px;
margin: 0 auto;
position: relative;
top: -50px;
}
#innerCircle {
width: 90px;
height: 90px;
background: white;
-moz-border-radius: 70px;
-webkit-border-radius: 70px;
border-radius: 70px;
position: absolute;
top: 25px;
right: 25px;
}
#rect1 {
width: 20px;
height: 90px;
background: white;
transform: rotate(30deg);
-ms-transform: rotate(30deg); /* IE 9 */
-webkit-transform: rotate(30deg); /* Safari and Chrome */
position: absolute;
top: 50%;
left: 5px;
}
#rect2 {
width: 20px;
height: 90px;
background: white;
transform: rotate(-30deg);
-ms-transform: rotate(-30deg); /* IE 9 */
-webkit-transform: rotate(-30deg); /* Safari and Chrome */
position: absolute;
top: 50%;
right: 5px;
}
#cover {
width: 150px;
height: 80px;
background: white;
position: absolute;
top: 0px;
left: 0px;
}
http://jsfiddle.net/bnSe7/
Hoặc bạn có thể làm một cái gì đó như thế này, uốn cong hai bên và sử dụng Tính năng xoay CSS3 để có được ba hình dạng:
http://jsfiddle.net/RqWtC/1/
Bạn có thể sẽ phải sử dụng HTML5 canvas để đạt được hình dạng phức tạp chính xác mà bạn đang yêu cầu:
http://www.html5canvastutorials.com/tutorials/html5-canvas-custom-shapes/
Nguồn
2013-04-14 08:48:04
Sử dụng '' thẻ, cho phép bạn vẽ bên trong một yếu tố ngăn chặn , tôi nghĩ đó là cách dễ nhất để đạt được những gì bạn mong muốn. –
Imperative
@Hoạt động bạn có nghĩa là sử dụng HTML5? Bạn có thể tạo mẫu không? Khả năng tương thích của trình duyệt với phần tử này là gì? –
đã xem trang này: rất nhiều mẫu: http://www.html5canvastutorials.com/tutorials/html5-canvas-tutorials-introduction/ – Imperative