2016-09-15 80 views
1

錨留我在屏幕上顯示的4名主播:使屏幕上的

I have 4 anchors displayed on screen

哈弗錨後放大,他們推上一個DIV在屏幕之外:

After Hover anchors enlarge and they push the last div out of the screen.

#box1{ 
 
    height: 100%; 
 
    width: 25%; 
 
    background-color: black; 
 
    transition: all 500ms ease-in-out; 
 
    
 
} 
 

 
#box1:hover{ 
 
    height: 100%; 
 
    width: 30%; 
 
    left:-5%; 
 
    
 
} 
 

 
#box2{ 
 
    height: 100%; 
 
    width: 25%; 
 
    background-color: green; 
 
transition: all 500ms ease-in-out; 
 
    
 
} 
 

 
#box2:hover{ 
 
    height: 100%; 
 
    width: 30%; 
 
    left:-5%; 
 
} 
 

 

 
#box3{ 
 
    height: 100%; 
 
    width: 25%; 
 
    background-color: blue; 
 
    
 
    
 
    
 
    
 
    
 
    transition: 500ms ; 
 
    
 
} 
 

 
#box3:hover{ 
 
    width: 30%; 
 
    height: 100%; 
 
    left:-5%; 
 
    
 
    
 
} 
 
#box4{ 
 
    height: 100%; 
 
    width: 25%; 
 
    background-color: darkviolet; 
 

 
    
 
} 
 

 
#box4:hover{ 
 
    height: 100%; 
 
    width: 30%; 
 
    left:-5%; 
 
    float: right; 
 
} 
 

 
.box { 
 
    float: left; 
 
    
 
} 
 

 
.boxdiv{ 
 
    height: 100%; 
 
    width: 100%; 
 
    position:fixed; 
 
}
 <div class="boxdiv"> 
 
    <a id="box1" class="box" > 
 
    <div> 
 
     
 
     </div> 
 
    </a> 
 
    <a id="box2" class="box"> 
 
    <div> 
 
     
 
     </div> 
 
    </a> 
 
    <a id="box3" class="box"> 
 
    
 
    </a> 
 
    <a id="box4" class="box"> 
 
    <div> 
 
     
 
     </div> 
 
    </a> 
 
</div>

如何讓錨點放大並將最後一個錨點留在屏幕上?我想要錨點放大,但紫色錨點也留在視圖中。

+0

你有什麼要發生在其他三個錨?它們應該縮小而徘徊的那個放大? – bbodien

+0

發佈完整的代碼或做一個小提琴,並給這個鏈接,使 –

+0

如果你做一個更大,你必須使其他人更小... –

回答

4

Flexbox可以做到這一點。

* { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
.red { 
 
    background: #f00; 
 
} 
 
.green { 
 
    background: #0f0; 
 
} 
 
.blue { 
 
    background: #00f; 
 
} 
 
.orange { 
 
    background: orange; 
 
} 
 
div { 
 
    height: 150px; 
 
    display: flex; 
 
} 
 
.parent a { 
 
    flex: 1 1 25%; 
 
    transition: flex-basis .5s ease; 
 
} 
 
.parent a:hover { 
 
    flex: 1 0 30%; 
 
}
<div class="parent"> 
 
    <a href="#1" class="box red"></a> 
 
    <a href="#2" class="box blue"></a> 
 
    <a href="#3" class="box green"></a> 
 
    <a href="#4" class="box orange"></a> 
 
</div>