How can I achieve this ribbon effect with CSS?

talena6

I am trying to achieve this effect. I want the two bars on each side to extend to the edge of the page. This is the closest I've come. I obviously need to flip the "folds" somehow, and I need to get each light blue bar to extend to the edge of the page.

http://jsfiddle.net/vPJ8g/

<div id="ribbon">
    <span id="content">Call us today! 555-555-5555</span>
</div>
*{margin:0px;padding:0px;}

html {
    width:100%;
        height:100%;
        background:#CCC;
  text-align: center;
    }

#ribbon {
    padding: .5em 2em;
    margin: 0;
    margin-top: 5%;
    position:relative;
    color: #ffffff;
    font: 20px 'Arial', sans-serif;
    text-align: center;
    background: #5f85b4;
    display: inline-block;
    }

#ribbon:before, #ribbon:after {
    content: "";
    width:1em;
    top:-.5em;
    position:absolute;
    display:block;
    border: .9em solid #1eb2df;
    z-index:-2;
    }

#ribbon:before {
    left:-1.5em;
    }

#ribbon:after {
    right:-1.5em;
    }

#content:before, #content:after {
    content:"";
    bottom:2.1em;
    position:absolute;
    display:block;
    border-style:solid;
    border-color: #2c4059 transparent transparent transparent;
    z-index:-1;
    }

#content:before {
      left: 0;
      border-width: .5em 1em 0 0;
    }

#content:after {
      right: 0;
      border-width: .5em 0 0 1em;
    }
Axel

You can use display: table; and display: table-cell; and some markup changes to achieve the results you are going for.

I removed your #content as it's a redundant identifier. You can use ancestor selections from the #ribbon to achieve the same results, without hogging a unique ID.

HTML:

<div id="ribbon">
    <div>
        <span>Call us today! 555-555-5555</span>
    </div>
</div>

CSS:

#ribbon {
    display: table;
    margin: 0;
    margin-top: 5%;
    position:relative;
    color: #ffffff;
    font: 20px 'Arial', sans-serif;
    text-align: center;
    width: 100%
}

#ribbon:before, #ribbon:after {
    content: "";
    width:25%;
    top:-.5em;
    position:absolute;
    display: table-cell;
    border: .9em solid #1eb2df;
    z-index:-2;
    }

#ribbon:before {
    left:-1.5em;
}

#ribbon:after {
    right:-1.5em;
}

#ribbon > div {
    margin: 0;
    display: table-cell;
    position: relative;
    width: 53%;
}

#ribbon span {
    display: block;
    color: #ffffff;
    font: 20px 'Arial', sans-serif;
    text-align: center;
    background: #5f85b4;
    padding: .5em 2em;
    position: relative;
}

#ribbon span:before, #ribbon span:after {
    content:"";
    bottom:2.1em;
    position:absolute;
    display: block;
    border-style:solid;
    border-color: #2c4059 transparent transparent transparent;
    z-index:-1;
    top: -10px;
}

#ribbon span:before {
    left: 0;
    border-width: .5em 1em 0 0;
}

#ribbon span:after {
    right: 0;
    border-width: .5em 0 0 1em;
}

Example: http://jsfiddle.net/vPJ8g/4/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I achieve this text stroke effect with CSS?

From Dev

How do I achieve this effect with css (image)

From Dev

How can I achieve this hover effect?

From Dev

How to achieve this CSS effect

From Dev

How can i achieve the bootstrap styling effect for a simple select dropdown-Jquery/CSS

From Dev

How can in achieve full background smoke effect in Javascript or CSS

From Dev

How can I achieve the "View slide-in" effect in react native?

From Dev

How can I achieve the effect of MS remote desktop on Linux?

From Dev

How can I achieve a hover effect like so?

From Dev

How can I achieve a wraparound effect in an arcade-like game?

From Dev

How can I achieve this Positioning with CSS?

From Dev

How can i achieve this style in Html/Css?

From Dev

How can I render country flags as a ribbon, using CSS only?

From Dev

How can i make this effect in css?

From Dev

How to achieve a CSS footer "curtain" effect?

From Dev

How to achieve a CSS footer "curtain" effect?

From Dev

How can I achieve underneath diagonal strikethrough text in CSS?

From Dev

How can I achieve a parallax moving background with CSS and JS?

From Dev

How can I achieve the effect of a double line going through some text but not on top of it? Image in description

From Dev

How can I achieve a scrollable circular text effect similar to http://thisiskiosk.com/

From Dev

How can I achieve this view?

From Dev

How can I achieve setOnLongClickListener?

From Dev

How can I achieve this view?

From Dev

How can I redraw the ribbon UI Elements

From Dev

How can I create a CSS "well" effect similar to bootstrap but deeper?

From Java

How can I make a CSS glass/blur effect work for an overlay?

From Dev

How can I make an effect of fading shadow with css3?

From Dev

How I can add highlight effect on outside the area of selection with CSS?

From Dev

How can i use hover effect on after element with css?

Related Related

  1. 1

    How can I achieve this text stroke effect with CSS?

  2. 2

    How do I achieve this effect with css (image)

  3. 3

    How can I achieve this hover effect?

  4. 4

    How to achieve this CSS effect

  5. 5

    How can i achieve the bootstrap styling effect for a simple select dropdown-Jquery/CSS

  6. 6

    How can in achieve full background smoke effect in Javascript or CSS

  7. 7

    How can I achieve the "View slide-in" effect in react native?

  8. 8

    How can I achieve the effect of MS remote desktop on Linux?

  9. 9

    How can I achieve a hover effect like so?

  10. 10

    How can I achieve a wraparound effect in an arcade-like game?

  11. 11

    How can I achieve this Positioning with CSS?

  12. 12

    How can i achieve this style in Html/Css?

  13. 13

    How can I render country flags as a ribbon, using CSS only?

  14. 14

    How can i make this effect in css?

  15. 15

    How to achieve a CSS footer "curtain" effect?

  16. 16

    How to achieve a CSS footer "curtain" effect?

  17. 17

    How can I achieve underneath diagonal strikethrough text in CSS?

  18. 18

    How can I achieve a parallax moving background with CSS and JS?

  19. 19

    How can I achieve the effect of a double line going through some text but not on top of it? Image in description

  20. 20

    How can I achieve a scrollable circular text effect similar to http://thisiskiosk.com/

  21. 21

    How can I achieve this view?

  22. 22

    How can I achieve setOnLongClickListener?

  23. 23

    How can I achieve this view?

  24. 24

    How can I redraw the ribbon UI Elements

  25. 25

    How can I create a CSS "well" effect similar to bootstrap but deeper?

  26. 26

    How can I make a CSS glass/blur effect work for an overlay?

  27. 27

    How can I make an effect of fading shadow with css3?

  28. 28

    How I can add highlight effect on outside the area of selection with CSS?

  29. 29

    How can i use hover effect on after element with css?

HotTag

Archive