I am making a seamless CSS pattern on the web. I know this is totally nonsense and non-practical at all. But it is just for the sake of having fun.
http://codepen.io/vennsoh/pen/iFKyo
I have done creating my first tile. Now I am thinking of a way to repeat it to fill up the whole background.
Can I complete this feat by just using HTML and CSS? Or must I use javascript to complete this?
-
Here are my steps if using javascript, correct me or suggest better ways:
-
I might want to make things move around, each polygon changes color, etc. It won't be static. I am not looking for a background-image solution.
Thanks, Venn.
To make a background image not repeat in HTML, specify no-repeat in the background-repeat property or the background shorthand property. The background image is set to 'no-repeat' using the 'background-repeat' property. The above example uses the background-repeat property to set the image to no-repeat .
To avoid the background image from repeating itself, set the background-repeat property to no-repeat .
CSS Syntax background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit; Note: If one of the properties in the shorthand declaration is the bg-size property, you must use a / (slash) to separate it from the bg-position property, e.g. background:url(smiley.
The background-repeat CSS property sets how background images are repeated. A background image can be repeated along the horizontal and vertical axes, or not repeated at all.
Actually this is possible with only html and css. The problem in your example is that every part of background will overlap when you set background-repeat
property because they have different size, so you just need to resize and position your shapes differently. The easy way to do this in your case is set one background-size
for every shape (size of desired complete pattern) and change their position accordingly.
I've modified part of your example to give you an idea of how it should look like: http://codepen.io/anon/pen/pnxyd
Just add,
float:left;
to the css, and then just make multiple copies of the div, just like here...http://codepen.io/anon/pen/rlDqh
I guess this should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With