Skip to content Skip to sidebar Skip to footer

Is There A Way To Curve An Element?

is there a way (probably with webGL, maybe also with three.js) to curve an html element inwards? (So it looks like the new panoramic samsung TV, for example). Just to be clear - I

Solution 1:

Not sure if there is a direct way , but here is a hack with :before and :after pseudo element to achieve an inward curve.

#video-player {
  width: 200px;
  height: 150px;
  background: #ccc;
  position: relative;
}
#video-player:after,
#video-player:before {
  position: absolute;
  height: 150px;
  width: 400px;
  border-radius: 50%;
  background: white;
  z-index: 1;
  content: " ";
}
#video-player:after {
  top: 120px;
  left: -100px;
}
#video-player:before {
  top: -120px;
  left: -100px;
}
<div id="video-player">

</div>

Solution 2:

TL;DR: No, you can not curve an HTML element as of 2016/2

You said you didn't want to do this but, you could try rendering a curved plane video and your UI curved with it in WebGL (or three.js) all manually implemented (not using HTML elements). There's an example of video in three.js here

The biggest obstacle will be that currently getting video into WebGL is somewhat heavy. Video larger than a certain size might run too slow.


Post a Comment for "Is There A Way To Curve An Element?"