CSS (3) & HTML Cut edge

后端 未结 2 2041
天涯浪人
天涯浪人 2021-01-18 22:54

This has already been asked, but I need it in a different way. Please have a look at the image below to see the nav bar I try to realize:

相关标签:
2条回答
  • 2021-01-18 23:02

    Looks like a static image for the edges will be the only way (unless you want to get technical and use canvas but that would be silly). You could get the angled edge with a rotated block, but you'd run into problems with the shadow. The text inside the bar doesn't seem like it'd be a problem though - for reference, those nav bars are usually implemented as flat lists.

    Sorry I couldn't be of more help !

    0 讨论(0)
  • 2021-01-18 23:26

    Rough demo: http://jsfiddle.net/W82UV/3/

    enter image description here

    I think this covers the crux of your difficulties, i.e. the edge skew, drop shadow, and border.

    <div id="top">
        The top bar
    </div>
    <div id="container">
        <div id="background">        
        </div>
        <nav>
            Test
        </nav>
    </div>
    
    #top{  
        background-color: #f0f0f0;
        border-bottom: 1px solid #555;
        box-shadow: 8px 8px 8px #aaa;
    }
    
    #container {
        position: relative;
        top: -1px;
        overflow: hidden;
        height: 96px;
    }
    
    #background {
        background-color: #f0f0f0;
    
        position: absolute;
        top: -1px;
        left: -32px;
        border: 1px solid #555;
    
        width: 400px;
        height: 64px;
        box-shadow: 8px 8px 8px #aaa;
    
       -webkit-transform: skew(-20deg); 
       -moz-transform: skew(-20deg); 
       -o-transform: skew(-20deg);
       -ms-transform: skew(-20deg); 
       transform: skew(-20deg);
    }
    

    Tested in IE 8 (doesn't skew), 9, 10, FF, and Chrome. Note that I would probably rearrange the markup a little to be cleaner for the final solution (better class names and/or IDs), and position everything proportionately.

    0 讨论(0)
提交回复
热议问题