2

thank you for all the years that I've never had to post a question and simply just searched!

Now, I'm trying to draw an arrow with a DIV. Example: http://i.imgur.com/wZBgv.png

So far code such as that below will draw a triangle: http://i.imgur.com/9nr3b.png

.arrow-small {
position: absolute;
bottom: 0;
left: 0;
width: 0; 
height: 0;
border-style: solid;
border-width: 80px 600px 50px 600px; 
border-color: transparent transparent blue transparent;
}

One method I've tried has been to create a smaller filled triangle to place on top of the large one which would create the arrow outline that I'm looking for, however I can not find a way to make the top div show the page background to complete the effect.

For clarity, my questions:

1) How does one create a backgroundless arrow with a div?

2) Or, how does one show the body background in a div ontop of another div that is not transparent?

4

1 回答 1

2

jsFiddle 演示:荧光绿箭头

我认为这行不通,因为您正在用其他不透明的东西覆盖不透明的东西。如果您能够使用 CSS3,以下内容可能适合您的需求:

<html>
  <head>
    <style>
      .chevron {
        position: absolute;
        width: 50px;
        height: 10px;
        top: 20px;
        background-color:red;
      }
      .left
      {
        left: 0px;
        -webkit-transform: rotate(340deg);
        -moz-transform: rotate(340deg);
        -o-transform: rotate(340deg);
        -ms-transform: rotate(340deg);
        transform: rotate(340deg);
      }
      .right
      {
        left: 43px;
        -webkit-transform: rotate(20deg);
        -moz-transform: rotate(20deg);
        -o-transform: rotate(20deg);
        -ms-transform: rotate(20deg);
        transform: rotate(20deg);
      }
    </style>
  </head>
  <body>
    <div class='chevron left'></div>
    <div class='chevron right'></div>
  </body>
</html>

我在这个页面上发现了转换,这是在回答这个问题时给出的,听起来很接近你的问题。

于 2012-12-31T04:34:48.497 回答