是否可以在CSS中使用CSS [英] Is it possible to have a CSS within a CSS
本文介绍了是否可以在CSS中使用CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在网站上工作,而且我对级联样式表的功能感到好奇。我有一个图像,当用户将鼠标悬停时,我希望其他元素出现在它上面。
例如一个普通的图像,当用户将鼠标悬停在它上面时,我想在其上显示两个按钮
I am working on a site and I''m curios on the functionality of cascade style sheets. I have an image and I want other elements to appear on it when the user hovers.
e.g. A plain image, when user hovers over it I want to display two buttons on it
.image
{
background image: url;
}
.image:hover
{
.buttonNext
{
backgroun-image: url;
margin: 5px;
}
.buttonPrevious
{
backgroun-image: url;
margin: 10px;
}
}
这甚至是可能还是我应该研究CSS嵌套和分组?
Is this even possible or should I look into CSS nesting and grouping?
推荐答案
不,这不是怎么回事CSS是专门设计的。
是的,它们是级联的,但不是这种意义上的。 CSS样式只放在一个扁平的单级列表中。
Cascadeness来自HTML中的元素层次结构,它们的父子关系,而不是CSS。一个基本原则是:父继承:如果未指定属性,它将从父元素继承。你能看出它是如何由于这个事实而级联的吗?您可以在此处找到关于样式优先级方案的其他详细信息: http:// en。 wikipedia.org/wiki/CSS#CSS_Priority_scheme_.28highest_to_lowest.29 [ ^ ]。
-SA
No, this is not how CSS is designed.
Yes, they are cascade, but not in this sense. CSS styles are put just in a flat single-level list.
"Cascadeness" comes from the hierarchy of elements in HTML, their parent-child relationship, not CSS. One basic principle is this: "Parent inheritance: If a property is not specified, it will be inherited from a parent element". Can you see how it cascades due to this fact? You can find other detail on style priority scheme here: http://en.wikipedia.org/wiki/CSS#CSS_Priority_scheme_.28highest_to_lowest.29[^].
—SA
这篇关于是否可以在CSS中使用CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文