This time I will bring you CSS to make hexagons filled with image backgrounds, and CSS to make hexagons filled with image backgrounds. What are the precautions?. Here are practical cases. Let’s take a look. one time.
The implementation principle of hexagon is actually obtained by rotating three overlapping rectangles, as shown in the following figure:
In order to obtain a positive hexagon, two rectangles are rotated The angle must be -60deg and 60deg, and the rectangle aspect ratio must be Math.sqrt(3): 1
So first we have to create three rectangles:
<p> </p><p></p> <p></p> <p></p>
We set three The width and height of the rectangle are 60px and 104px respectively, the background color is blue, .hexagonitem_left is rotated by -60deg, .hexagonitem_right is rotated by 60deg, and .hexagonitem_center is not rotated.
.hexagon { width: 60px; height: 104px; position: relative; margin: 200px auto; } .hexagonitem { width: 100%; height: 100%; background: blue; position: absolute; top: 0; left: 0; } .hexagonitem_left { transform: rotate(-60deg); } .hexagonitem_right { transform: rotate(60deg); }
In this way, we simply get a regular hexagon.
So how can we make the blue background turn into a picture? It is actually very simple. The above three rectangles actually only play a shaping role. In fact, they should be set to visibility : hidden, we need to add a rectangular child element to each of the three rectangles and set it to visibility: visible.
The width and height of the three sub-elements need to just cover the previous blue hexagon.
The code is as follows, you can study it carefully
nbsp;html>Document <p> </p><p></p> <p></p> <p></p>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
CSS weird box model and standard box model How to use
CSS to implement accordion layout
The above is the detailed content of CSS to create a hexagon filled image background. For more information, please follow other related articles on the PHP Chinese website!

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment