Some CSS3 fun stuff to try out...

Some CSS3 fun stuff to try out...

by Mary Evans -
Number of replies: 10
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

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

smile

Average of ratings:Useful (2)
In reply to Mary Evans

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

by Miriam Laidlaw -
Picture of Plugin developers

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

In reply to Miriam Laidlaw

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

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

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.

In reply to Mary Evans

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

by 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!
Average of ratings:Useful (3)
In reply to Danny Wahl

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

by Luis de Vasconcelos -

What image did you use?

In reply to Luis de Vasconcelos

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

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

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

corner-image

In reply to Mary Evans

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

by 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!)
In reply to Danny Wahl

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

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

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! smile

In reply to Mary Evans

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

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

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

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Cool!  I love this sharing of knowledge! smile

In reply to Mary Evans

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

by Brian Merritt -
Picture of 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!!!!