GithubHelp home page GithubHelp logo

suretarget / responsive-grid-of-hexagons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from web-tiki/responsive-grid-of-hexagons

0.0 2.0 0.0 992 KB

CSS responsive grid of hexagons

License: Apache License 2.0

CSS 28.21% HTML 71.79%

responsive-grid-of-hexagons's Introduction

#CSS and HTML responsive grid of hexagons.

View live demo

Responsive grid of hexagons demo

##Features

  • The hexagon grid is responsive according to the width of the container (#hexGrid)
  • Hexagons keep their aspect ratio according to their width
  • The number of hexagons per row is adaptive and changes from 5 to 2 on media query break points
  • A title and short text slide in on hexagon hover and focus
  • Hexagons and can be cycled through with tab (keyboard navigation)

Text and hover effect:

The CSS for the text and hover effect is identified in the hexagons.css stylesheet. You can remove it completely or change the hover effect, font, font-size...

Changing the number of hexagons per row:

The width of the .hex elements defines the number of hexagons per row. The CSS properties that need to be changed are all in the media queries under the HEXAGON SIZING AND EVEN ROW INDENTATION comment.
Each media query changes the number of hexagons per row.

To change the number of hexagons per row, you need to:

Width of .hex

Customize the with of the .hex elements with:

w = width of the .hex elements in percent
x = the number of hexagons you want on the odd rows (1st, 3rd, 5th...)

w = 100 / x

Example for 8 hexagons on odd rows (this means there will be 7 hexagons on even rows):

w = 100 / 8 = 12.5%

Indent even rows

The even rows (2nd, 4th,6th...) are indented with margin-left on the first hexagon of even rows.

The selector:
You can select that hexagon with the .hex:nth-child(an+b) selector (more info on on the nth-child() pseudo-class on MDN). To determine the selector, you can use this rule:

.hex:nth-child(an+b)

x = the number of hexagons on odd rows(1st, 3rd, 5th...)
Y = the number of hexagons on even rows(2nd, 4th, 6th...)
a = x + y
b = x + 1

Example for 8 hexagons on odd rows (this means there will be 7 hexagons on even rows):

x = 8
y = 7
a = 8 + 7 = 15
b = 8 + 1 = 9

The selector is : .hex:nth-child(15n+9)

Value of margin-left:
The value of margin left is half the width of one hexagon so for 8 hexagons on odd row :

with of hexagons = 12.5% (see "width of .hex")
margin-left = 12.5 / 2 = 6.25%

responsive-grid-of-hexagons's People

Contributors

web-tiki avatar poi33 avatar controversial avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.