Ответ 1
Этот вопрос заставлял меня работать в течение некоторого времени, это, по-видимому, очень сложно сделать только с CSS. Мне удалось добиться эффекта (бумага перевернулась с рамкой вокруг элемента), которую вы хотели, но для этого требуется много CSS, и я не знаю, как далеко вы хотите идти. Я применил border-radius
в верхнем правом углу и использовал треугольник для перекрытия радиуса границы. Это не покрывало всего border radius
, поэтому я использовал span
для формирования 2 фигур для наложения оставшегося промежутка.
Посмотрите на эту скрипку для результата, любые улучшения приветствуются
CODE:
body {
background: #444 url('http://leaverou.me/ft2010/img/darker_wood.jpg') bottom;
}
.arrow_box {
color:red;
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
height:400px;
border-radius:0 300px 0 0; /* here we give the box a round corner on the top right side */
}
.arrow_box:after, .arrow_box:before { /* we create 2 triangles in the top right corner, one for the border and one for the filling */
-ms-transform:rotate(-135deg); /* rotate to make the triangle have the right angle */
-webkit-transform:rotate(-135deg);
transform:rotate(-135deg);
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
top:42px;
right:-20px;
}
/* here we position the triangles in the top right corner */
.arrow_box:after {
border-color: rgba(200, 265, 0, 0);
border-bottom-color: #00b7d5;
border-width: 100px;
left: 100%;
margin-left: -240px;
}
.arrow_box:before {
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 105px;
left: 100%;
top:39px;
margin-left: -245px;
}
/* we still have a massive gap next to the triangle, so we fill it up with 2 rectangles. One on the left side of the triangle and one on the bottom side of the triangle, we also will give them a border to finish the line around the element */
.arrow_box span {
border-top: 4px solid #c2e1f5;
position:absolute;
width:150px;
height:140px;
background-color:black;
right:140px;
top:-4px;
background: #88b7d5;
}
.arrow_box span:after {
border-right: 4px solid #c2e1f5;
content: "";
position:absolute;
width:150px;
height:150px;
background: #88b7d5;
left:140px;
top:140px;
}
С CSS4 это будет намного легче сделать, здесь вы можете прочитать об этом;
http://dev.w3.org/csswg/css-backgrounds-4/#border-corner-shape