<script src="js/jquery.1.7.2.min.js" type="text/javascript"></script> <script src="js/jquery.arctext.js" type="text/javascript"></script> <script src="js/jquery.global.js" type="text/javascript"></script>
<script type="text/javascript"> jQuery(document).ready(function($) { $("#ex").arctext({ radius:210, //Độ cong của chữ dir:1 // 1 cong lên, -1 cong xuống }); }); </script> <h1 id="ex">Test thử cái coi</h1>Bạn có thể thay đổi các giá trị radius và dir để biết thêm về các tính năng của nó.
#ex{ // ID của thẻ h1 // CSS3 for all browser -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -o-transform: rotate(-90deg); -ms-transform: rotate(-90deg); transform: rotate(-90deg); }
<style type="text/css"> body{ font-family: Roboto; color: #6ABDC5; background:#6ABDC5 url(../images/background-puple.png) repeat; } article{ width: 900px; margin: 0 auto; } article section{ width: 400px; height: 400px; position: relative; background: #fff; display: inline-block; // Thay thế float, giúp 2 đối tượng ngang hàng nhau border-radius: 50%;// Tạo vòng tròn text-align: center; margin-top: 50px; margin-right: 80px; cursor: pointer; } article section h1{ line-height: 400px; font-size: 30px; font-size: 180px; text-transform: uppercase; } article section p{ position: absolute; bottom: -40px; // Định vị trí cho thẻ p left: 20px; color: #fff; font-size: 25px; text-transform: uppercase; } article section:last-child{ margin-right: 0;// bỏ margin left cho section thứ 2 } </style> <article> <section id="Yes"> <h1>YES</h1> <p>Lorem ipsum dolor sit amet</p> </section> <section id="No"> <h1>NO</h1> <p>Lorem ipsum dolor sit amet</p> </section> </article>Sau đó bạn có thể xem thử, tuy nhiên nó vẩn chưa hoàn thành nhé. Giờ chúng ta sẽ nhúng Jquery vào.
<script type="text/javascript"> jQuery(document).ready(function($) { var sec = $("section"); sec.find("p").css('bottom', '50'); // set css này để che lại phần chữ trong thẻ p sec.find("p").arctext({radius:210,dir:-1}); // set arc text cho đoạn chữ // funtion hover có thể hiểu như thế này: // Khi hover vào section thì nó sẽ tìm thẻ p. // sau đó animate đẩy p xuống 40px để hiển thị ra ngoài. sec.hover(function(){ $(this).find('p').animate({ 'bottom':-40 // khi hover vào thì đẩy xuống 40px },"slow")},function(){ $(this).find('p').animate({ 'bottom':50 // khi đưa chuột ra khỏi section thì sẻ quay về vị trí cũ },"slow")// slow, fast hoặc ms }) }); </script>Bây giờ thì khi các bạn đưa chuột vào chữ YES hoặc NO thì phần desciption sẽ hiện ra. Khá thú vị phải không các bạn. Trong phần tiếp theo, mình sẽ hướng dẫn các bạn làm mây, chim, cá diễn hoạt, tương tự như website của mình.
© Chia sẻ 2013 . Powered by Blogger . Blogger templates . New Blogger Templates