效果:倒金字塔型效果
效果圖:
要求:
1.左邊選中的內(nèi)容放到右邊金字塔中(追加到右側(cè));
2.右邊的內(nèi)容不可重復
3.刪除后,新加入的元素要根據(jù)之前元素情況重新排序,不能打亂倒金字塔效果(如果上面比較短,新追加的比較長,新加的要放到短的上面)
刪除部分后,1,3為新加入的,要實現(xiàn)的效果順序為:1,2,3,4,5
本來是想根據(jù)div的背景位置做比較,但最后沒能拿到,問題3就一直沒解決掉,有沒有js厲害的朋友給幫忙解決一下,小妹在此先謝過,抱拳?。?!
說明:每列的梯形是用背景圖做的,每個相差31px。
部分代碼:
<div class="FL selectedTag">
<h3 class="titles">選中標簽</h3>
<ul>
<li class="tags relative" flag="0" style="background-position-y: -93px;"><div class="centerDiv" aval="dc_digital_apptype:2" title="APP偏好:微信">APP偏好:微信</div><span class="absolute close" style="right: 29px;">x</span></li><li class="tags relative" flag="1" style="background-position-y: -155px;"><div class="centerDiv" aval="dc_digital_databand:D" title="手機流量:1-5MB">手機流量:1-5MB</div><span class="absolute close" style="right: 41px;">x</span></li><li class="tags relative" flag="2" style="background-position-y: -155px;"><div class="centerDiv" aval="dc_digital_resident:livingORworking" title="常駐:居住和工作">常駐:居住和工作</div><span class="absolute close" style="right: 41px;">x</span></li><li class="tags relative" flag="3" style="background-position-y: -93px;"><div class="centerDiv" aval="dc_digital_sex:B" title="性別:女">性別:女</div><span class="absolute close" style="right: 29px;">x</span></li><li class="tags relative" style="background-position-y: -124px;"><div class="centerDiv" aval="dc_digital_hascar:A" title="是否車主:是">是否車主:是</div><span class="absolute close" style="right: 35px;">x</span></li><li class="comNum">
<div class="comNumCon ml_10 FL">當前可操作人數(shù) <b>0人</b></div>
<button id="countPeople" class="FL t_c LH30 ml_10 medium_btn border_btn_blue borderRadius colorDefault" style="background-color: #6CA9FC">計算人數(shù)
</button>
</li>
</ul>
</div>
.selectedTag{
width: 300px;
}
.tags,.comNum{
margin-bottom: 2px;
width: 300px;
height: 30px;
color: #8f9eb2;
font-size: 12px;
}
.tags{
background: url("../images/tagBg.png") no-repeat;
background-position-x: 0px;
}
.comNumCon{
width: 180px;
margin-bottom: 2px;
height: 30px;
font-size: 12px;
color: #ffffff;
background: url("../images/tagBg.png") no-repeat -52px -301px;
}
.comNumCon b{
font-size: 14px;
font-weight: 900;
}
.tags:nth-last-child(2){
margin-bottom: -2px;
}
.close{
width: 16px;
height: 16px;
top:7px;
font-size: 12px;
font-weight: lighter;
background-color: #ffffff;
border-radius: 50px;
color: #bfcad6;
text-align: center;
line-height: 14px;
cursor: pointer;
/*background: url("../images/close20.png") no-repeat 0 0;*/
}
.tags div,.comNum div{
width: 180px;
text-align: center;
height: 100%;
line-height: 30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
不知道你的每個div的長度是怎么計算的?是固定的不同的類型不同的長度?還是看里面字符串的內(nèi)容?
不管是按照什么規(guī)則制定的長度,我的理解是你把金字塔的div固定,變的只不過是里面的內(nèi)容,那么給每個內(nèi)容定義為一個對象,放到數(shù)組里,再排序,排序好了再放上去:
data = [{
text: '性別啥哎哎',
width: 10
}, {
text: 'shifdsadsa哎',
width: 12
}]
data.sort(function(a,b){
return a.width - b.width
})
然后循環(huán)data,創(chuàng)建dom
北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構,是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
北大課工場是北京大學校辦產(chǎn)業(yè)為響應國家深化產(chǎn)教融合/校企合作的政策,積極推進“中國制造2025”,實現(xiàn)中華民族偉大復興的升級產(chǎn)業(yè)鏈。利用北京大學優(yōu)質(zhì)教育資源及背
博為峰,中國職業(yè)人才培訓領域的先行者
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務負責iOS教學及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術, 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術顧問,美國Dachieve 系統(tǒng)架構師,美國AngelEngineers Inc. 系統(tǒng)架構師。