如何使用CSS实现这种视觉效果 [英] How to achieve this visual using CSS
本文介绍了如何使用CSS实现这种视觉效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要仅使用CSS和仅一个高度和宽度为300px的div创建以上视觉效果。我尝试了渐变,但无法得到相同的结果。有人可以帮忙吗?
I need to create the above visual using only css and only one div having 300px height and width. I tried gradient but could not get anything same. Anyone can help please?
推荐答案
渐变是个好主意,您甚至可以添加内容,无论渐变大小如何,只要将其大小设置为正方形即可:
gradient is a fine idea, you could even add content, no matter the size for the gradient, as long as you size it to be a square:
div {
background-color: red;
border-radius: 0 0 50% 50%;
background-image:
linear-gradient(-45deg, transparent 75%, blue 75%),
linear-gradient(45deg, transparent 75%, yellow 75%),
linear-gradient(to top, green 50%, transparent 50%);
height: 300px;
width: 300px;
transition:0.5s;
}
div:hover {
height: 150px;
width: 150px;
}
/* fun */
div {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 2.5em;
color: white;
text-shadow: 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black;
box-shadow: 0 0 5px gray, inset 0 0 0 3px white,inset 0 0 5px black;
}
<div>Hover me</div>
这篇关于如何使用CSS实现这种视觉效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文