久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

CSS:當我為段落設(shè)置 ID 時,懸停效果不起作用

CSS :hover effect not working when I set an ID to the paragraph(CSS:當我為段落設(shè)置 ID 時,懸停效果不起作用)
本文介紹了CSS:當我為段落設(shè)置 ID 時,懸停效果不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有以下 css3 過渡效果:

I have the following css3 transition with ease effect:

HTML

<div class="button">     
    <a href="#" onMouseOver="clicksound.playclip()"></a>
    <p id="myId" class="top"></p>            
</div>

CSS

 * {
     padding: 0;
     margin: 0;
 }
 .button {
     width: 180px;
     margin-top: 45px;
 }
 .button a {
     display: block;
     height: 40px;
     width: 180px;
     /*TYPE*/
     color: black;
     font: 17px/50px Helvetica, Verdana, sans-serif;
     text-decoration: none;
     text-align: center;
     text-transform: uppercase;
 }
 .button a {
     background:url(http://imageshack.com/a/img819/761/dqj.gif);
     margin: -50 0 0 0;
     z-index: -1;
 }
  p#myId {
     background: url(http://imageshack.com/a/img854/1921/9ft3.png);
     display: block;
     height: 40px;
     width: 167px;
     margin: -40px 0 0 5px;
     z-index:-1;
     /*TYPE*/
     text-align: center;
     font: 12px/45px Helvetica, Verdana, sans-serif;
     color: #fff;
     /*POSITION*/
     position: absolute;
     /*TRANSITION*/
     -webkit-transition: margin 0.1s ease;
     -moz-transition: margin 0.1s ease;
     -o-transition: margin 0.1s ease;
     -ms-transition: margin 0.1s ease;
     transition: margin 0.1s ease;
 }
 .button:hover .top {
     margin: -67px 0 0 5px;
     line-height: 35px;
 }
 /*ACTIVE*/
 .button:active .top {
     margin: -70px 0 0 5px;
 }

如果我在 CSS 中將 p#myId 選擇器更改為 p,它可以工作(按鈕在懸停時上升),否則不會.

If I change the p#myId selector to p in CSS, it works (the button goes up on hover), otherwise it won't.

在 jsFiddle 上運行演示

推薦答案

問題是處理你的 :hover 行為的選擇器有一個較低的Specificity 比默認行為的規(guī)則(p#id 選擇器).

The problem is that the selector handling your :hover behavior has a lower Specificity than the rule for the default behavior (p#id selector).

改變這個

.button:hover .top {

到這里

.button:hover #myId.top {

將解決問題:運行示例

will solve the problem: Running example

您還可以將 id 應(yīng)用于父對象(比如說 <div id="container">),然后使用

You can also apply an id to a parent object (lets' say <div id="container">), and then use

#container .button:hover .top {

<小時>

必讀:CSS 特定性規(guī)范

例子:

這篇關(guān)于CSS:當我為段落設(shè)置 ID 時,懸停效果不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結(jié)果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: 美女久久视频 | 国产高清自拍视频在线观看 | 综合久久久 | 精品国产免费一区二区三区演员表 | 久久久久国产精品一区 | 免费亚洲婷婷 | 玖玖国产| 欧美日韩国产中文字幕 | 国产激情视频在线 | 国产亚洲www | 亚洲 欧美 综合 | 欧美精品网站 | 亚洲视频中文字幕 | 精品亚洲一区二区 | 在线一区 | 久久久久国产精品 | 男女在线网站 | av黄色在线播放 | 欧美精品99 | 国产在线视频在线观看 | 亚洲成年影院 | 天天操网| 亚州毛片 | 欧美激情视频一区二区三区在线播放 | 性高湖久久久久久久久3小时 | 九色av| 欧美一区二 | 夜夜草天天草 | 亚洲精品视频在线观看视频 | 国产一区二区三区四 | 成人av一区二区三区 | 久久久久久免费精品一区二区三区 | 久久久久久国产精品 | 午夜小电影 | 久久国产一区 | 中文字幕视频在线观看 | 久久亚洲一区 | 九九热在线视频免费观看 | 亚洲成人精品久久 | 99riav国产一区二区三区 | 欧美日韩精品久久久免费观看 |