0
我有一個按鈕被點擊,一旦點擊它的變化從濃縮到崩潰,反之亦然。我首先將它作爲一個普通塊附加到我的內容區域,一旦點擊就展開成爲一個菜單。然後,我繼續將相同的按鈕附加到菜單本身並替換該值,以表示左箭頭。該按鈕具有作爲永久性默認設置的課堂旁邊的按鈕,並且可以適當地在旁邊摺疊和旁邊濃縮之間切換。我的問題是,一旦按鈕被添加到菜單裏,它會忽略掉旁邊的css及其功能。任何和所有的幫助將不勝感激。謝謝JQuery添加div CSS類+功能被忽略
jQuery的
(function ($, Drupal){
Drupal.behaviors.asideColldense = {
attach : function() {
$('<div class=aside-button><p>▶</p></div>').appendTo('#content');
$('.aside-button').addClass('aside-condensed');
var aside = $('#block-panels-mini-aside-navigation');
aside.hide();
function collapseOrCondense(event) {
aside.toggle();
$('.aside-button').toggleClass('aside-collapsed');
$('.aside-button').toggleClass('aside-condensed');
if($('.aside-button').hasClass('aside-collapsed')) {
$('.aside-button p').contents().replaceWith('◀');
$('.aside-button').appendTo('.aside-menu li.menu-path-hosting');
}
else{
$('.aside-menu li.menu-path-hosting .aside-button p').contents().replaceWith('▶');
$('.aside-menu li.menu-path-hosting .aside-button').appendTo('#content');
}
}
$('.aside-button').on('click', collapseOrCondense);
}
}
})(jQuery, Drupal);
的CSS
.aside-menu ul.nice-menu li {
border: .118em solid rgb(90,90,90);
float: left;
background: rgb(38,38,38);
}
.aside-menu {
margin: 0;
padding: 0;
z-index: 10;
display: inline-block;
}
.aside-condensed {
position: fixed;
display: inline-block;
top: 50vmin;
left: 0%;
margin: 0;
width: 5vmin;
z-index: 10;
}
.aside-collapsed {
display: inline-block;
/* float: right; */
margin: 0;
}
.aside-button p {
background-color: rgb(38,38,37);
text-align: center;
cursor: pointer;
border: rgb(222,222,222) solid 2px;
border-left: none;
padding: 17.5% .5% 17.5% 0;
margin: 0;
font-size: 2.5vmin;
}
.aside-button p:hover {
background-color: rgb(222,222,222);
color: rgb(50,50,41);
border: rgb(50,50,41) solid 2px;
border-left: none;
padding-bottom: 13.5%;
}
.aside-collapsed p {
border: none;
font-size: 1.75vw;
}
.aside-collapsed p:hover {
background-color: rgb(38,38,37);
color: rgb(255,255,255);
border: none;
border-left: none;
padding-bottom: 13.5%;
}
PICTURE
冷凝,工作
合攏按鈕黃色highlighed,忽略預留按鈕的CSS和jQuery,所以它也拒絕關閉
請勿將「固定」之類的pseduo標籤添加到您的問題中;相反,請標記您接受的答案。 – meagar 2014-10-02 01:48:19
這是我的意圖,雖然我必須等待2天才能將其標記爲此,但我使用「固定」標籤作爲臨時替代品,以達到相同的目的。但經驗談話,所以不好聽老闆。 – Bakajuice 2014-10-02 05:52:35