Some CSS3 fun stuff to try out...

Some CSS3 fun stuff to try out...

Mary Evans -
Vastausten määrä: 10

Hi,

I have been reading up on CSS3 and tested one of the ideas I read in Eric Meyer's book Smashing CSS Professional Techniques for Modern Layout. It's using multiple images as a background.

So with the following images at the ready...

together with the CSS...

#page-header {
width: 100%;
height: 160px;
border: 1px dotted #C69;
background:  url([[pix:theme|t-lt]]) no-repeat 0 0,  url([[pix:theme|t-rt]]) no-repeat 100% 0,  url([[pix:theme|b-lt]]) no-repeat 0 100%, url([[pix:theme|b-rt]]) no-repeat 100% 100%; }

I achived this...

CSS3

hymy

Arviointien keskiarvo:Useful (2)
Vastaus Mary Evans

Re: Some CSS3 fun stuff to try out...

Miriam Laidlaw -
Kuva: Plugin developers

Nice! What's the browser support for this, though?

Vastaus Miriam Laidlaw

Re: Some CSS3 fun stuff to try out...

Mary Evans -

Well it works in Firefox so I am guessing Chrome, Opera & Safari but I didn't test it in any of them. I think it works in IE if you add the relevent JS script.

Vastaus Mary Evans

Re: Some CSS3 fun stuff to try out...

Danny Wahl -
That's awesome Mary, I was inspired and whipped this up to showcase transforms. It looks a bit "hacky" but it's real CSS:
#content,
#content-wrapper {
    width: 400px;
    min-height: 200px;
    display: block;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

#content::before { /* Top Left: no transform */
    content: "";
    z-index: -1;
    position: absolute;
    width: 80px;
    height: 80px;
    background: url(bg.png) 0 0 no-repeat;
    top: 0;
    left: 0;
}

#content::after { /* Top Right: flip horizontally */
    content: "";
    z-index: -1;
    position: absolute;
    width: 80px;
    height: 80px;
    background: url(bg.png) 0 0 no-repeat;
    -moz-transform: scaleX(-1);
    transform: scaleX(-1);
    top: 0;
    right: 0;
}

#content-wrapper::before { /* Bottom Left: flip vertical */
    content: "";
    z-index: -1;
    position: absolute;
    width: 80px;
    height: 80px;
    background: url(bg.png) 0 0 no-repeat;
    -moz-transform: scaleY(-1);
    transform: scaleY(-1);
    bottom: 0;
    left: 0;
}

#content-wrapper::after { /* Bottom Right: flip horizontal + vertical */
    content: "";
    z-index: -1;
    position: absolute;
    width: 80px;
    height: 80px;
    background: url(bg.png) 0 0 no-repeat;
    -moz-transform: scaleX(-1) scaleY(-1);
    transform: scaleX(-1) scaleY(-1);
    bottom: 0;
    right: 0;
}
Does the same thing you did, but with only 1 image!
Arviointien keskiarvo:Useful (3)
Vastaus Danny Wahl

Re: Some CSS3 fun stuff to try out...

Luis de Vasconcelos -
Kuva: Particularly helpful Moodlers

What image did you use?

Vastaus Luis de Vasconcelos

Re: Some CSS3 fun stuff to try out...

Mary Evans -

Daniel may have used this image...as it can be flipped and mirrored using transforms...

corner-image

Vastaus Mary Evans

Re: Some CSS3 fun stuff to try out...

Danny Wahl -
yup that's the one I used, sorry I didn't write it for a specific place in Moodle, I just wrote it to show using generic wrappers and containers. I did a bigger write-up and a demo here: http://iyware.com/css3-multiple-backgrounds-vs-transforms/ (not a shameless plug, it's actually relevant!)
Vastaus Danny Wahl

Re: Some CSS3 fun stuff to try out...

Mary Evans -

You could use a sprite image in place of the 4 images that would cut down on image loading, an less CSS to process too, not to mention less divs also! hymy

Vastaus Mary Evans

Re: Some CSS3 fun stuff to try out...

Danny Wahl -
yeah,but then you have to deal with sprites! There's nothing I dislike more than sprites.
Vastaus Danny Wahl

Re: Some CSS3 fun stuff to try out...

Mary Evans -

Cool!  I love this sharing of knowledge! hymy

Vastaus Mary Evans

Re: Some CSS3 fun stuff to try out...

Brian Merritt -
Kuva: Particularly helpful Moodlers

Just a quick note Mary to say I was struggling to get multiple background images / sprites working with Moodle and this post saved me probably a day of work!  Many thanks!!!!