0

Hi,

I have come across a quite challenging situation. I sort of understand how to make all kinds of different shapes with CSS but what about when its a container with something inside that on top of that has a background like this:

enter image description here

(please see it on a black background for a better view)

as you may notice, its a list with radio buttons inside an irregular shape that has a semi-transparent image as the background. How to achieve this effect with CSS only? I dont think pseudo-elements will work at all because of the transparent background which has to be uniform all across the container and along the lines. It would look like a complete mess if I overlap pseudo-elements. Also, the left side borders have a totally transparent background. Any ideas please?

Thank you.

ul {
  background: rgba(0, 0, 0, 0) url("back.png") no-repeat scroll 0 0;
  border: 1px solid gray;
  margin: 20px;
  padding: 5px;
  width: 100px;
}

li {list-style:none;}

ul::before {
    border: 1px solid gray;
    content: "";
    display: block;
    height: 124px;
    margin: 0 0 0 -17px;
    position: absolute;
    top: 20px;
    width: 5px;
}
ul::after {
    border: 1px solid gray;
    content: "";
    height: 5px;
    left: 28px;
    position: absolute;
    top: 150px;
    width: 110px;
}
<ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
  <li><input type="radio"> Option 4</li>
  <li><input type="radio"> Option 5</li>
  <li><input type="radio"> Option 6</li>
</ul>
Cain Nuke
  • 2,843
  • 5
  • 42
  • 65

3 Answers3

2

Svg solution

That shape is so spesial i would create a png file to use as its background.
Now if for some reason you cant have a png background, you could use an svg:

body {
  margin: 0;
  
}
.container {
  background-image: url("http://www.lorempixel.com/500/500/");
  position: relative;
  height: 300px;
  width: 200px;
  /*color: white; Looks reallly bad*/
}
.container svg {
  position: relative;
  height: 100%;
  width: 100%;
}
.container h3{
  position: absolute;
  left: 27%;
  top: 4%;
}
.container label {
  position: absolute;
  left: 32%;
  top: 30%;
}
.container label:nth-of-type(2) {
  top: 40%;
}
.container label:nth-of-type(3) {
  top: 50%;
}
.container label:nth-of-type(4) {
  top: 60%;
}
.container label:nth-of-type(5) {
  top: 70%;
}
<div class="container">
  <svg viewBox="0 -5 60 110">
    <path d="m10,0 50,0 0,90 -45,0 0,-60 -5,-10, 0,-20z" fill="#bbb" fill-opacity="0.9" stroke="black" />
    <path d="m0,0 0,20 5,10 0,60 5,0 0,-60 -5,-10, 0,-20" fill="none" stroke="#ccc"/>
    <path d="m5,93 55,0 -2.5,2.5, -2.5,0 -2.5,2.5 -43.5,0 -4,-2.5z" fill="#bbb" fill-opacity="0.9" stroke="black"/>
  </svg>
  <h3>Some content</h3>
  <label>
    <input type="radio" name="radioSelc" />Option 1</label>
  <label>
    <input type="radio" name="radioSelc" />Option 2</label>
  <label>
    <input type="radio" name="radioSelc" />Option 3</label>
  <label>
    <input type="radio" name="radioSelc" />Option 4</label>
  <label>
    <input type="radio" name="radioSelc" />Option 5</label>
</div>

Is a responsive shape, so it works with different sizes.
The aspect ratio is 2/3 so 0.66%.
height: 300px; -> 400px -> 600px etc
width: 200px; -> 266px -> 400px etc

Persijn
  • 14,624
  • 3
  • 43
  • 72
1

You can also use multiple background-image, with either slices of your designed box (classic way) or gradients, or a mix of both eventually.

gradients idea example :

h3, ul,li {
  margin:0;
  padding:0;
  display:block;
}
h3 {
  text-indent:-20px;
}
div {
  width:100px;
  margin:1em 1em 3em;
  padding:5px 10px 5px 60px;
  background:
    linear-gradient(to right,  transparent 23px,
      gray 23px,  gray 29px, transparent 29px,transparent 34px, black 34px) 0 bottom no-repeat,
    linear-gradient(to right, gray 1px,  gray 6px,transparent 6px,transparent 10px, black 10px) 0 0 no-repeat,
    linear-gradient(to right, gray 1px, transparent 1px, transparent 5px, gray 5px, gray 6px,transparent 6px,transparent 11px, black 11px, black 12px, gray 12px) 0 0 no-repeat,
    linear-gradient(60deg, transparent 20px, gray 20px, gray 21px, transparent 21px, transparent 25px, gray 25px, gray 26px,transparent 26px, transparent 30px, black 30px, black 31px, gray 31px) 0 20px no-repeat,
    linear-gradient(to right,  transparent 23px,
      gray 23px, gray 24px, transparent 24px, transparent 28px,gray 28px, gray 29px, transparent 29px,transparent 34px, black 34px, black 34px, gray 35px) 0 61px no-repeat;
  
 background-size:100% 1px,100% 1px, 100% 20px ,100%  41px, 100% 100%;
  border-right:1px solid;
  position:relative;
  float:left;
}

div:after {
  content:'';
  position:absolute;
  top:100%;
  right:0;
  left:22px;
  margin-top:5px;
  height:16px;
  border-top:solid 1px;
  background:
    linear-gradient(to right,black 1px, gray 1px) 0 0 no-repeat,
    linear-gradient(-60deg,transparent 3px, black 3px, black 5px, gray 5px) top right no-repeat,
    linear-gradient(-60deg,transparent 24px, black 24px, black 25px, gray 25px) right 5px no-repeat,
    linear-gradient(60deg,transparent 3px, black 3px, black 4px, gray 4px) left 9px no-repeat,
    linear-gradient(-60deg,transparent 3px, black 3px, black 4px, gray 4px) 5px 9px no-repeat,
    linear-gradient(black,black) 0 5px no-repeat,
    linear-gradient(black,black) 0 9px no-repeat,
    linear-gradient(black,black) 3% 15px no-repeat;
    ;
  background-size:80% 9px, 40% 5px, 40% 4px, 20% 6px, 30% 6px, 97% 1px, 81% 1px, 29% 1px
  
}

body {
  background:yellow;
<div>
  <h3>Some options</h3>
  <ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
  <li><input type="radio"> Option 4</li>
  <li><input type="radio"> Option 5</li>
  <li><input type="radio"> Option 6</li>
</ul>
</div>
<div>
  <h3>Some options</h3>
  <ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
</ul>
</div>
<div>
  <h3>Some options</h3>
  <ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
  <li><input type="radio"> Option 4</li>
  <li><input type="radio"> Option 5</li>
  <li><input type="radio"> Option 6</li>
  <li><input type="radio"> Option 7</li>
  <li><input type="radio"> Option 8</li>
</ul>
</div>

slice example:

h3, ul,li {
  margin:0;
  padding:0;
  display:block;
}

div {
  width:100px;
  margin:1em;
  padding:5px 5px 30px 40px;
  float:left;
  background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH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IGG2Yq0VIhLP85iIhFmE2QoARwcAsdbyJkOFiPiVaSzM3PASkQBoRhuveDzxPIKI8CaLeZOlAoDl1R9bsrbXk4gIO7rbZ8MLEeGNv7d4W/yvjZsvO/8R/AmjjxmyZJCjZQAAAABJRU5ErkJggg==) bottom  no-repeat;
  background-size:114px auto ,114px calc(100% - 52px);
  }
label {
  display:inline-block;
  background:gray;
  border-radius:100%;
  padding:0px 1px 2px 2px;
  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAAB50RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNS4xqx9I6wAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNS8yOS8xNrtVQFkAAAHBSURBVCiRXcvPbhJRGEDx89G5c+8MDFgp01RjLDQp2gZX7Czdie9hF/Z16Kr4Erhm1bBw40KMC9G0c2PiggkJprUWqjO9LvwT41mfn0RRhNYapRSP9/ZcvV5nfX0dgDRNsdbycjAQrTXGGDwRQUR4dnDg9vf3pfEfSKyl2Wy6o15PROQXeH546J52u7Kzs+s+nFr5aD8DUF2t0G63CYNARMT1j4/Fe9Ltuk6nI9vNB7x6/UbCMKRarSIiZN+vefvuPa3dh1wtFjKZTJy31Wiw1WhwmnyiWCwRlUqsrBTQvkLfilhcLUjTlD9foRbHxHHMl/NzKuUIoxVR0VApBUTFgNrabbIsJ45janGMx++0UoSBJtA+gfHxfR8RwTkoFkPyPCfPcwqz2YzZbMZadZWb7MffWSmFUgrnbohKJebzOfP5nIJNEs6ShHt377BcLlheXyMiAGRZRp7nhGHozpIEmyR4w+FQtptNFxgjrdYjLr5ecHn5DeUrlKcwxjAej2U0GrmTkxPxnHO86PcFcIvlUuqbm2xsbAAwnU5JrGU0GrmjXk+01ki5XEZrjed5dDodd/8fkE6nWGsZDAZijEFrzU8XuqnWNgsutQAAAABJRU5ErkJggg==) center no-repeat;
  background-size:90% 90%;
}
label input {
  display:block;
  margin:0;
  }
<div>
  <h3>options</h3>
  <ul>
  <li><label><input type="radio"/></label> Option 1</li>
  <li><label><input type="radio"/></label> Option 2</li>
  <li><label><input type="radio" checked/></label> Option 3</li>
  <li><label><input type="radio"/></label> Option 4</li>
  <li><label><input type="radio"/></label> Option 5</li>
  <li><label><input type="radio"/></label> Option 6</li>
</ul>
</div>
<div>
  <h3>Some options</h3>
  <ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
</ul>
</div>
<div>
  <h3>Some options</h3>
  <ul>
  <li><input type="radio"> Option 1</li>
  <li><input type="radio"> Option 2</li>
  <li><input type="radio"> Option 3</li>
  <li><input type="radio"> Option 4</li>
  <li><input type="radio"> Option 5</li>
  <li><input type="radio"> Option 6</li>
  <li><input type="radio"> Option 7</li>
  <li><input type="radio"> Option 8</li>
</ul>
</div>
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
  • This is really interesting. So you can pretty much draw any kind of line with linear-gradient?? – Cain Nuke May 29 '16 at 21:56
  • @CainNuke ,in theorie yes, but it should not be abused. you have linear and radial and repeating as well ... too much can slow down light machines – G-Cyrillus May 29 '16 at 22:10
  • I didnt know that. Thanks for the information. Im gonna try out your solution. It can be used along with a background image such a png, right? – Cain Nuke May 29 '16 at 22:27
  • @CainNuke yes of course, you can also use rgba() hsla() colors – G-Cyrillus May 29 '16 at 23:06
  • Do you know like how much load would take for the example you provided? On my computer runs fine but I dont have any other to test. – Cain Nuke May 30 '16 at 12:07
  • @CainNuke If these are the only gradients you have on the page it can be fine indeed, but if you do the whole design of a site based only on gradients and background-size, it will be taking lots of calculation. For testing you may look at https://en.wikipedia.org/wiki/Virtual_machine – G-Cyrillus May 30 '16 at 12:14
  • Thanks for your advice. I think I will have in fact more than 1 of these shapes so I hope thats not a problem. – Cain Nuke Jun 03 '16 at 17:29
0

You can do this with clip-path. The CSS is on line 302 onwards. Mae sure the clipped element is positioned absolute and keep in mind browser support is not the best. The are sandbox playgrounds to generate the paths, its quite easy.

  -webkit-clip-path: polygon(1% 3%, 3% 9%, 18% 21%, 54% 20%, 
  83% 63%, 66% 76%, 15% 83%, 25% 45%);

Link to Codepen, hover over the drinks:-)

http://codepen.io/damianocel/pen/KdobyK

damiano celent
  • 721
  • 6
  • 12
  • Unfortunately as you said, that solution lacks browser support. I am using firefox and I cant even see the effect. Also, seems like you are using jquery as well. – Cain Nuke May 29 '16 at 09:21
  • Yeah, Mozilla has the biggest issues with this property. It's interesting you are mentioning this, I am converting the JS code for that to vanilla JS right now, I should be done in 20mins.:-) The JS has nothing to do with the polygon path though, it simply performs better than Jquery. For a cross browser solution, it's easiest to get the shape from a photo editor. – damiano celent May 29 '16 at 09:38
  • You mean to use a image instead? It it was only one then no problem. However, I have many shapes and that would require a lot of images. – Cain Nuke May 29 '16 at 09:40
  • I suppose canvas or svg might resolve this as well, but I am a pure beginner in both. – damiano celent May 29 '16 at 09:43
  • clip-path could work after all on firefox too, but it needs a different approach like this: https://jsfiddle.net/do9cyohy/ – Cain Nuke May 29 '16 at 10:30
  • YEah, svg path, thanks for this, i will learn this right now, as the possible effects are impressive and lightweight:-) – damiano celent May 29 '16 at 11:17