Help with some CSS

Joined
Mar 29, 2023
Messages
14
Reaction score
1
I have been trying to get my head around this code and have failed miserably after numerous attempts. So i hope some one could please come to my rescue and tell me where i've gone wrong.

CSS:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Placing a smiley before and after a paragraph</title>
    <style>
        p::before {
            content: url('smiley.gif');
        }
        p::after {
            content: url('smiley.gif');   
        }
    </style>
</head>
<body>
    <p>This is just some text.</p>
    <p>This is just some more text.</p>
</body>
</html>

Big thanks for any help and advice.
 
Joined
Jul 4, 2023
Messages
475
Reaction score
58
Just as a curiosity I'll add ... you can "manage" pseudo-elements like ::before and ::after, even in that way ;)

e.g. [ full: on-line ]

CSS:
      :root {
        --main-width: 290px;
      }
      div {
        width: var(--main-width);
        font: 500 1.1rem/1.1 system-ui, monospace;
      }   
      p::before,
      p::after {
        margin: 0 .5em;
        line-height: 1.6;
      }
      p::before {
                    /* link for demonstration purposes only */
        content: url('https://picsum.photos/16/16?random=1');     
      }
      p::after {
                    /* link for demonstration purposes only */
        content: url('https://picsum.photos/16/16?random=2'); 
      }
      p.one:hover::before,
      p.one:hover::after {
        content: '';
        margin: 0 .95em;
      }
      p.two:hover::before {
        content: url('https://picsum.photos/16/16?random=2');
      }
      p.two:hover::after {
        content: url('https://picsum.photos/16/16?random=1');
      }
      p.three {
        position: relative;
        padding-left: 2em;
      }
      p.three::before,
      p.three:after {
        position: absolute;
        transition: all 2s ease-in-out;     
      }
      p.three::before {     
        left: 0;
        z-index: -1;
      }
      p.three::after {
        right: calc(1em / 3);
        z-index: 1;
      }   
      p.three:active::before {
        transform: translatex(calc(var(--main-width) - 250%));
        z-index: 1;
      }
      p.three:active::after {
        transform: translatex(calc((var(--main-width) - 250%) * -1));
        z-index: -1;
      }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top