Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to create text and button on a mobile screen image?

Let said i have an iphone image. I want to create text and button on the iphone screen image. This will let user look like the iphone image is works. May i know how can i do that?

1 Answer

You could set the image to the background of a div element using CSS and give it height and width properties that match up with the image size. Then inside of that element, you could create a div with some padding on each side. Inside of that, you could make a textarea element that takes up the remaining pixels which should equal the size of the screen. Also, make the background of that textarea transparent so that it shows the actual screen behind it. You'd have to figure out the exact CSS on your own though.

Actually here you go. Here's a starting point. You're going to have to tweak this to get exactly what you were looking for but this should help you get going:

<!DOCTYPE html>
<html>
<head>
    <title>Something</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div class="outer">
    <div class="inner">
        <textarea></textarea>
    </div>
</div>
</body>
</html>
.outer {
    width: 300px;
    height: 500px;
    background: black;
}

.inner {
    color: white;
    padding: 20px 10px;
}

textarea {
    height: 460px;
    width: 280px;
    margin: 0;
    padding: 0;
    background: transparent;
    color: white;
}

I'll leave you to figure out the button on your own.