Web page Draw Slash

Source: Internet
Author: User
Tags count tostring

After accustomed to the web of the normal horizontal line and vertical bar, occasionally to point Slash will give a unique feeling. First look at the effect of the slash

A simple slash adds a lot to the page, but how do you draw it in a Web page? When it comes to drawing, you might have thought of it, just a little bit. Here is the code

<script type="text/javascript">
     $().ready(function(){
       function wirteline(o){
         var myHeight=o.parent().height();  //获得高度和宽 度
         var myWidth=o.parent().width();
         var count=myHeight<=myWidth? myHeight:myWidth;
         var divstring=" ";
         for(var i=0;i<=count;i++) //循环绘制
         {
           divstring+="<div class='line'  style='top:"+i.toString()+"px;left:"+(myWidth--).toString() +"px;'></div>";
           //为什么不直接这样呢?
           //o.append("<div class='line'  style='top:"+i.toString()+"px;left:"+(myWidth--).toString() +"px;'></div>");

         }
         o.append(divstring);  //如果像上面那样重复获取对象 ,会有点慢
       }

       wirteline($('.linebox'));
     });
   </script>

The basic principle is a div a pixel, which consists of a diagonal line based on the position of the div. I will not say the specific code, there are comments on it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.