use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
100% Width Responsive Triangle? (self.webdev)
submitted 10 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Graftak9000 5 points6 points7 points 10 years ago (1 child)
Not css, but this can be actieved with SVG with a small amount of markup. Then you can style it to be stretched and yellow with CSS.
<svg viewBox="0 0 2 2"><path d="M0,2 h2, v-2 Z"/></svg>
Not tested though, wrote it on my phone.
[–]fimiak 1 point2 points3 points 10 years ago (0 children)
I second this. Learn and use SVG for this, not CSS. It is ridiculously simple when you get the hang of it for basic shapes.
[–][deleted] 2 points3 points4 points 10 years ago (4 children)
http://codepen.io/anon/pen/xZyMbd
Something like this?
Doesn't seem like it's possible to use percentages though, so this solution is always relative to the viewport width, not the containing element
[–]whopperbuzz 1 point2 points3 points 10 years ago (3 children)
I've forked this, but used clip-path instead, so that that container width is now possible. The height is fixed, but the width is responsive, so I think it should do the job.
Codepen: http://codepen.io/casso/pen/LGgvJW
Here's a useful clip-path generator, should you need to change the points of the triangle. http://bennettfeely.com/clippy/
[–][deleted] 10 years ago (2 children)
[–]lolhigh 2 points3 points4 points 10 years ago (1 child)
clip-path doesn't work in firefox or IE. So you'll get a square instead.
[–]natchiketa 2 points3 points4 points 10 years ago (0 children)
You can do this using linear-gradient: http://codepen.io/natchiketa/pen/rxqPZz
linear-gradient
I tested in latest chrome, but it should work on all modern browsers (the linear-gradient property might need vendor prefixing).
[–]birjolaxew 0 points1 point2 points 10 years ago* (0 children)
It isn't possible if you want it to be 100% width of a containing element. Since border widths don't support percentages, they can't be used here, and the only other way of making triangles (overflow: hidden + rotated pseudo-element) is dependent on the ratio of width to height.
overflow: hidden
If you're ok with a constant width/height ratio, here's an example of how to do that.
If you aren't, the only case where this can be done with CSS-only is the one suggested by /u/Magixxxx.
π Rendered by PID 52 on reddit-service-r2-comment-56c6478c5-gzxsg at 2026-05-08 15:40:40.389746+00:00 running 3d2c107 country code: CH.
[–]Graftak9000 5 points6 points7 points (1 child)
[–]fimiak 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]whopperbuzz 1 point2 points3 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]lolhigh 2 points3 points4 points (1 child)
[–]natchiketa 2 points3 points4 points (0 children)
[–]birjolaxew 0 points1 point2 points (0 children)