Make an open book with only CSS/HTML

Today we'll be making a blank, open book style template like the one above using only CSS and HTML.

Before we begin, you'll want a basic understanding of HTML and CSS. It will make it easier to follow this tutorial.

Open your text editor and let's make an html document:

You can assign a background color or image to the body like I did, if you want to.

Now, let's add the actual book cover by adding this to the CSS between the style tags:

and this to the HTML between the body tags:

The border radius is optional, depending on if you want rounded corners or not. It's absolutely positioned so it will be vertically and horizontally centered. This is what we have so far:

Let's assign a background image to add texture, and a drop shadow to make it look more convincing. Add these properties to the #cover selector in the CSS:

I've also added a padding of 10 pixels, to make room for the pages we're about to add.

Let's add our first page. Add this to the CSS:

I've added a padding of 2 pixels to make room for the next page, and adjusted the width and height to make up for the padding (so 820x580 to 818x578)

I've also added a self-explanatory drop shadow, border radius, and background color.

And this to the HTML, inside the "cover" div:

Here's how it looks so far:

We'll now add depth by creating multiple pages on top. For these we'll do the same thing with the page we've just created. Add this to the CSS:

I've added a background image to page 3 for texture, as this will be the page our book will be opened up to.

Add this inside of the "page1" div in the HTML:

and add this inside of the "page2" div we've just created:

Now this is what we have:

So it doesn't just look like one big page, we need a division down the middle.

Make a div called "line" (or whatever you want to call it) inside of the "page3" div:

And let's style it by adding this to the CSS:

I set a margin of "0 auto" to center it, as well as a height equal to that of page 3 and a width of just 1 pixel. This way it appears as a line. I've also added a background color so we can see it, and a box shadow to create another illusion of depth.

Here's what we have:

We are technically done, but to make sure our content appears in the right places, we need to make more divs.

Inside our "page 3" div, above the "line" div, make another div called "leftpage":

And let's do the same for the right page. Add this under the "leftpage" div we just created:

Now let's style them so they are in the right positions. We'll do this by using floats. Add this to the CSS:

And that's it. Now we can add our own content in the left or right pages by writing inside either the "leftpage" div or the "rightpage" div:

Here's some more examples of what I've done with it:

Thanks for reading!!