

Text-align: center margin-top: -130px white-space: nowrap position: relative z-index: 5 Width: 0 height: 0 border-style: solid border-width: 150px 100vw 0 100vw border-color: $dark transparent transparent transparent position: relative z-index: 1 display: flex justify-content: center
#Simple css drawing how to
I have attached below an example of how to use the code you provided along with HTML5 Canvas to dynamically create shapes.ĭisplay: flex justify-content: center position: relative z-index: 10 Most good web pages have a combination of all three since some are better than others in different ways. So with that being said, the choice is really up to you to choose between SVG, CSS, and HTML5 CANVAS to render your images.

HTML5 canvas can be more frutstrating to scale to the correct sizes.ĬSS has the benefit of being more lightweight and faster in terms of loading, however it is much more difficult to do complex multilayer animations and other things such as Layer Masks/shader effects as you would have to manually calculate all of the simple geometry rather than having the computer do it. You can simply change the viewport of an SVG element and achieve an image that has been scaled. On the flip side, SVG is easier to scale to different sizes than canvas is. You can also draw on an SVG inline element using Javascript, but its not as simple without an additional javascript library like SVG.JS or SNAP.JS You can dynamically draw on a Canvas using Javascript. (There are also other 3rd party plugins like shockwave/flash etc)īut basically, Canvas is the easier to use alternative to SVG for one reason: its javascript friendly.

There are basically two ways to render more complicated animations and drawings (i mean complicated as in a Tetris game on a web page or something) SVG is mainly a tool for animations and intricate artwork. Use SVG for advanced shapes and animations.ĬSS is much faster for displaying shapes if you are thinking about the time to transfer the data from the http server to the connecting client as long as the shapes are simple drawings that aren't animated and don't contain custom curvature or pathways or multiple layers. Also try SVG I have created some great effects using SVG libraries in the past, things that would have not been possible using CSS alone, they even work in IE9 ( not that it's supported any more ). To me it seems the route less obstructed and easiest to learn if you want things quickly. My suggestion for SVG animation would be to use a javascript library. SVGs are able to be animated via manipulating the styles on the svg itself however this ( depending on what your goal is ) can become a very deep rabbit hole. You can embed them directly or through an HTML img tag, you can even use javascript libraries to inject them into your application. Depending on how you implement SVG you can do certain things. Use SVG for more complex shapes and animations. Some may say this isn't future proof and could break on any update. Like you mentioned when you are using CSS to generate custom shapes all you are doing is adding borders of box shadows to create the illusion of the shapes you desire. Was also just thinking - to add more room to the top - to add a solid box shadow to create the illusion that it sort of a irregular pentagon ( Found on YouTube here) So, since I had to muck around to get the text working (still not perfect with scaling), I am wonder whether going the route of SVG's would be the way, that is if SVG's are more efficient at the getting the job done/loading time. Learn more about our services by selecting one belowīorder-color: $dark transparent transparent transparent Sorry, below is the code I am using at the moment to achieve the effect, along with an image of what I am looking to achieve (Unfortunately, the person who designed the image didn't supply code for the design, only the image). I just looked into SVG's wondering if it is a viable option. TL DR: What is better - cross-browser/load-time wise - when wanting to have shapes on a webpage. (These shapes will be 1000px+ wide, hence why I didn't want to use images.) Couldn't find any soild information about this certain topic, so any information regarding SVG's are appreciated. So, I am wondering, would it be simpler to use SVG's instead of these CSS 'hacks' to achieve my shapes. I wanted to use CSS since, it is going to load faster than if I was to use images.įew days pass, I stumble upon SVG's, I have always seen them around the web but have never delved into them. I have been playing around with shapes in my website using CSS and it has been all right but a bit annoying at times when manipulating them since, for instance a triangle, it is really a rectangle with a border.įor a guide on shape creating in CSS I am using CSS-tricks article about it.
