r/learnjavascript • • 3d ago

How can I improve my satiric project

Hello,

Not a long time ago, I created a satiric announcement of a new phone. For that, I used HTML, CSS but still not JS and I want to improve my announcement.

Do you have any idea for that.

Project

<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="UTF-8">
        <title>Buy the new mPhone.</title>
        <style>


            body {
                font-family: cursive;
            }


            h1 {
              text-align: center;
              color: rgb(0, 0, 50);
              text-shadow: 0.5px 0.5px 0.5px black;
              font-size: 50px;
            }


             h2 {
              text-align: center;
              color: rgb(0, 0, 70);
            }


            #image1 {
             width: 800px;
             position: relative;
             left: 310px;
            }


            #image1:hover {
             transition: 0.5s ease;
             transform: scale(1.03);
            }


            h3 {
                text-align: center;
                position: relative;
                bottom: 30px;
            }


             h4 {
                position: relative;
                bottom: 700px;
                left: 30px;
             }


             p {
                text-align: center;
                position: relative;
                bottom: 50px;
             }
        </style>
    </head>
    <body>
        <h1>Buy the new mPhone</h1>
         <h2>One of the best phones you will see.</h2>
         <img src="mPhone.png" id="image1">
         <h3>900$</h3>
         <h4>Mango</h4>
         <p>The cheapest phone of the year.</p>
    </body>
</html>
5 Upvotes

5 comments sorted by

4

u/Discordbothost 3d ago

I'd make the mPhone's storage picker your first bit of JS. Give each option a price and update the $900 heading when the selection changes. You could make the expensive option unlock a charger that still has to be bought separately.

2

u/Look386 3d ago

Thanks

2

u/Mbwiria_Godlee 3d ago

lol having to unlock the ability to pay extra for a charger is spot on for a parody site.

2

u/ChanhyoungLee 3d ago

The phone image isn't loading on the live link. The page asks for mPhone.png, but the host returns a 404 for it, so the file probably didn't get uploaded. Upload it next to index.html with the exact same name and case.

Then I'd fix the layout before adding JS. left: 310px and bottom: 700px only line up on your screen with the image loaded. On a phone the image runs off the right edge, and right now "Mango" ends up above the top of the page. For the image, swap that rule for:

#image1 { display: block; width: 800px; max-width: 100%; margin: 0 auto; }

For JS that fits the joke, make the price double every time someone clicks it. Put this in a script tag at the end of body:

document.querySelector("h3").onclick = e => e.target.textContent = parseInt(e.target.textContent) * 2 + "$";

2

u/Look386 3d ago

Thanks