2017-01-12 167 views
0

我有以下截圖:無法顯示DIV中的HTML CSS

enter image description here

如何顯示的箭頭,中間的字?我在一個div 8個分離圖像和其他在另一個DIV但無論哪種方式我不能顯示them.My代碼之間的箭頭:

function showHide(a) { 
 
    
 
    var div = document.getElementById("word"); 
 
    if (div.style.display == 'none') { 
 
     div.style.display = ''; 
 
\t $('#word').text(a); 
 
    } 
 
    else { 
 
    div.style.display = 'none'; 
 
    } 
 
}
body { 
 
\t display:flex; 
 
\t flex-flow:row wrap; 
 
\t margin:0; 
 
\t height:100vh; 
 
    } 
 
body:after { 
 
\t content:''; 
 
\t display:block; 
 
\t width:100%; 
 
\t order:1; 
 
    } 
 
.responsive { 
 
\t border:solid; 
 
\t margin:0; 
 
    } 
 
.responsive:nth-child(1) { 
 
\t margin-bottom:auto; 
 
\t margin-right:auto; 
 
\t order:0; 
 
    } 
 
.responsive:nth-child(2) { 
 
\t margin-bottom:auto; 
 
\t margin-left:auto; 
 
\t order:0; 
 
    } 
 

 
.responsive:nth-child(3) { 
 
\t margin-top:auto; 
 
\t margin-right:auto; 
 
\t order:2; 
 
    } 
 
.responsive:nth-child(4) { 
 
\t margin-top:auto; 
 
\t margin-left:auto; 
 
\t order:2; 
 
} 
 
span{ 
 
\t margin-top: 270px; 
 
\t margin-left: 610px; 
 
\t position: absolute; 
 
\t text-shadow: 0 0 3px #FFF000, 0 0 5px #0000FF; 
 
\t font-size: 40px; 
 
} 
 
p{ 
 
\t margin-top: 100px; 
 
\t margin-left: 570px; 
 
\t position: absolute; 
 
\t text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF; 
 
\t font-size: 70px; 
 
} 
 
.arrow { \t 
 
    position: absolute; 
 
\t margin-top: 300px; 
 
\t 
 
} 
 
div.1, div.2, div.3 { 
 
    display: inline-block; 
 
}
<div class="1" > 
 
<div class="responsive"> 
 
    <div class="img"> 
 
    <a target="_blank" href="animals/dog.jpg"> 
 
\t \t <audio id="sound1" src="audio/mother.mp3" ></audio><a onclick="document.getElementById('sound1').play(); showHide('Mother'); "><img src="family/mother.jpg" id="mother" alt="mother" width="220" height="160"></img></a> 
 
\t \t <span id="img1"></span> 
 
\t \t <audio id="sound2" src="audio/father.mp3" ></audio><a onclick="document.getElementById('sound2').play(); showHide('Father');"><img src="family/father.jpg" id="father" alt="father" width="220" height="160"></img></a> 
 
\t \t <span id="img2"></span> 
 
\t \t </br> 
 
\t \t <audio id="sound3" src="audio/sister.mp3" ></audio><a onclick="document.getElementById('sound3').play(); showHide('Sister');"><img src="family/sister.jpg" id="sister" alt="sister" width="220" height="160"></img></a> 
 
\t \t <span id="img3"> </span> 
 
\t \t <audio id="sound4" src="audio/brother.mp3" ></audio><a onclick="document.getElementById('sound4').play();showHide('Brother');"><img src="family/brother.jpg" id="brother" alt="brother" width="220" height="160"></img></a> 
 
\t \t <span id="img4"> </span> 
 
    </a> 
 
    </div> 
 
</div> 
 
    
 
    
 
    
 

 
<div class="responsive"> 
 
    <div class="img"> 
 
    <audio id="sound5" src="audio/apple.mp3" ></audio><a onclick="document.getElementById('sound5').play(); showHide('Apple');"><img src="fruits/apple.jpg" id="apple" alt="apple" width="220" height="160"></img></a> 
 
\t <span id="img5"> </span> 
 
\t <audio id="sound6" src="audio/banana.mp3" ></audio><a onclick="document.getElementById('sound6').play();showHide('Banana');"><img src="fruits/banana.jpg" id="banana" alt="banana" width="220" height="160"></img></a> 
 
\t <span id="img6"> </span> 
 
\t </br> 
 
\t <audio id="sound7" src="audio/orange.mp3" ></audio><a onclick="document.getElementById('sound7').play();showHide('Orange');"><img src="fruits/orange.jpg" id="orange" alt="orange" width="220" height="160"></img></a> 
 
\t <span id="img7"> </span> 
 
\t <audio id="sound8" src="audio/grape.mp3" ></audio><a onclick="document.getElementById('sound8').play();showHide('Grape');"><img src="fruits/grape.jpg" id="grape" alt="grape" width="220" height="160"></img></a> 
 
\t <span id="img8"> </span> 
 
    </div> 
 
</div> 
 
</div> 
 

 
<div class="2"> 
 
<span id="word" style="display:none"></span> 
 
</div> 
 

 
<div class="3"> 
 
<div class="responsive"> 
 
    <div class="img"> 
 
     <audio id="sound13" src="audio/cat.mp3" ></audio><a onclick="document.getElementById('sound13').play(); showHide('Cat');"><img src="animals/cat.jpg" id="cat" alt="cat" width="220" height="160"></img></a> 
 
\t <span id="img13"> </span> 
 
\t <audio id="sound14" src="audio/dog.mp3" ></audio><a onclick="document.getElementById('sound14').play();showHide('Dog');"><img src="animals/dog.jpg" id="dog" alt="dog" width="220" height="160"></img></a> 
 
\t <span id="img14"> </span> 
 
\t </br> 
 
\t <audio id="sound15" src="audio/monkey.mp3" ></audio><a onclick="document.getElementById('sound15').play();showHide('Monkey');"><img src="animals/monkey.jpg" id="monkey" alt="monkey" width="220" height="160"></img></a> 
 
\t <span id="img15"> </span> 
 
\t <audio id="sound16" src="audio/fox.mp3" ></audio><a onclick="document.getElementById('sound16').play();showHide('Fox');"><img src="animals/fox.jpg" id="fox" alt="fox" width="220" height="160"></img></a> 
 
\t <span id="img16"> </span> 
 
    </div> 
 
</div> 
 

 
<div class="responsive"> 
 
    <div class="img"> 
 
     <audio id="sound9" src="audio/window.mp3" ></audio><a onclick="document.getElementById('sound9').play();showHide('Window');"><img src="house/window.jpeg" id="window" alt="window" width="220" height="160"></img></a> 
 
\t <span id="img9"></span> 
 
\t <audio id="sound10" src="audio/table.mp3" ></audio><a onclick="document.getElementById('sound10').play(); showHide('Table');"><img src="house/table.jpg" id="table" alt="table" width="220" height="160"></img></a> 
 
\t <span id="img10"></span> 
 
\t </br> 
 
\t <audio id="sound11" src="audio/roof.mp3" ></audio><a onclick="document.getElementById('sound11').play();showHide('Roof');"><img src="house/roof.jpg" id="roof" alt="roof" width="220" height="160"></img></a> 
 
\t <span id="img11"> </span> 
 
\t <audio id="sound12" src="audio/floor.mp3" ></audio><a onclick="document.getElementById('sound12').play();showHide('Floor'); "><img src="house/floor.jpg" id="floor" alt="floor" width="220" height="160"></img></a> 
 
\t <span id="img12"> </span> 
 
    </div> 
 
</div> 
 
</div> 
 

 
<a href="first_page.html"><img class="arrow" src="arrow.gif" alt="Arrow"></a>

任何建議?

+0

哪裏是截圖? – Jere

+0

@jere截圖是在URL「在這裏輸入的形象描述」 –

+0

中的所有圖像,或什麼的中間? –

回答

0

你需要絕對定位包含的所有圖像,並使用頂部,左,轉變爲中心,它相對定位的div裏面的箭頭 - 雖然你也可以使用負利潤率,而不是變換。不要忘記供應商前綴。

.arrow {  
    position: absolute; 
    margin-top: 300px; 
    top: 50%; 
    left: 50%; 
    transform: translateY(-50%); 
    transform: translateX(-50%); 

} 
0

一對夫婦的一般性問題

  • img標籤是自閉合,這意味着你不應該把</img>
  • br也是自閉,但/應在年底不是開始,所以<br/>或只是<br>

到實際問題,你需要一個相對位置容器(因爲你想把它當作彎曲你應該使用inline-flex所以它不會擴展到整個寬度,然後進行絕對定位的箭頭並居中。
記住,一旦塊已經崩潰之一的,其他它不會工作)

function showHide(a) { 
 

 
    var div = document.getElementById("word"); 
 
    if (div.style.display == 'none') { 
 
    div.style.display = ''; 
 
    $('#word').text(a); 
 
    } else { 
 
    div.style.display = 'none'; 
 
    } 
 
}
body{ 
 
    height: 100vh; 
 
    margin: 0; 
 
} 
 
.container { 
 
    display: inline-flex; 
 
    flex-flow: row wrap; 
 
    position:relative; 
 
} 
 
.container:after { 
 
    content: ''; 
 
    display: block; 
 
    width: 100%; 
 
    order: 1; 
 
} 
 
.container > a{ 
 
    position:absolute; 
 
    top:50%; 
 
    left:50%; 
 
    transform:translate(-50%,-50%); 
 
} 
 
.responsive { 
 
    border: solid; 
 
    margin: 0; 
 
} 
 
.responsive:nth-child(1) { 
 
    margin-bottom: auto; 
 
    margin-right: auto; 
 
    order: 0; 
 
} 
 
.responsive:nth-child(2) { 
 
    margin-bottom: auto; 
 
    margin-left: auto; 
 
    order: 0; 
 
} 
 
.responsive:nth-child(3) { 
 
    margin-top: auto; 
 
    margin-right: auto; 
 
    order: 2; 
 
} 
 
.responsive:nth-child(4) { 
 
    margin-top: auto; 
 
    margin-left: auto; 
 
    order: 2; 
 
} 
 
span { 
 
    margin-top: 270px; 
 
    margin-left: 610px; 
 
    position: absolute; 
 
    text-shadow: 0 0 3px #FFF000, 0 0 5px #0000FF; 
 
    font-size: 40px; 
 
} 
 
p { 
 
    margin-top: 100px; 
 
    margin-left: 570px; 
 
    position: absolute; 
 
    text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF; 
 
    font-size: 70px; 
 
} 
 
div.1, 
 
div.2, 
 
div.3 { 
 
    display: inline-block; 
 
}
<div class="container"> 
 
    <div class="1"> 
 
    <div class="responsive"> 
 
    <div class="img"> 
 
     <a target="_blank" href="animals/dog.jpg"> 
 
     <audio id="sound1" src="audio/mother.mp3"></audio> 
 
     <a onclick="document.getElementById('sound1').play(); showHide('Mother'); "> 
 
      <img src="http://dummyimage.com/220x160?text=Mother" id="mother" alt="mother" width="220" height="160"> 
 
     </a> 
 
     <span id="img1"></span> 
 
     <audio id="sound2" src="audio/father.mp3"></audio> 
 
     <a onclick="document.getElementById('sound2').play(); showHide('Father');"> 
 
      <img src="http://dummyimage.com/220x160?text=Father" id="father" alt="father" width="220" height="160"> 
 
     </a> 
 
     <span id="img2"></span> 
 
     <br> 
 
     <audio id="sound3" src="audio/sister.mp3"></audio> 
 
     <a onclick="document.getElementById('sound3').play(); showHide('Sister');"> 
 
      <img src="http://dummyimage.com/220x160?text=Sister" id="sister" alt="sister" width="220" height="160"> 
 
     </a> 
 
     <span id="img3"> </span> 
 
     <audio id="sound4" src="audio/brother.mp3"></audio> 
 
     <a onclick="document.getElementById('sound4').play();showHide('Brother');"> 
 
      <img src="http://dummyimage.com/220x160?text=Brother" id="brother" alt="brother" width="220" height="160"> 
 
     </a> 
 
     <span id="img4"> </span> 
 
     </a> 
 
    </div> 
 
    </div> 
 

 

 

 

 
    <div class="responsive"> 
 
    <div class="img"> 
 
     <audio id="sound5" src="audio/apple.mp3"></audio> 
 
     <a onclick="document.getElementById('sound5').play(); showHide('Apple');"> 
 
     <img src="http://dummyimage.com/220x160?text=Apple" id="apple" alt="apple" width="220" height="160"> 
 
     </a> 
 
     <span id="img5"> </span> 
 
     <audio id="sound6" src="audio/banana.mp3"></audio> 
 
     <a onclick="document.getElementById('sound6').play();showHide('Banana');"> 
 
     <img src="http://dummyimage.com/220x160?text=Banana" id="banana" alt="banana" width="220" height="160"> 
 
     </a> 
 
     <span id="img6"> </span> 
 
     <br> 
 
     <audio id="sound7" src="audio/orange.mp3"></audio> 
 
     <a onclick="document.getElementById('sound7').play();showHide('Orange');"> 
 
     <img src="http://dummyimage.com/220x160?text=Orange" id="orange" alt="orange" width="220" height="160"> 
 
     </a> 
 
     <span id="img7"> </span> 
 
     <audio id="sound8" src="audio/grape.mp3"></audio> 
 
     <a onclick="document.getElementById('sound8').play();showHide('Grape');"> 
 
     <img src="http://dummyimage.com/220x160?text=Grape" id="grape" alt="grape" width="220" height="160"> 
 
     </a> 
 
     <span id="img8"> </span> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="2"> 
 
    <span id="word" style="display:none"></span> 
 
</div> 
 

 
<div class="3"> 
 
    <div class="responsive"> 
 
    <div class="img"> 
 
     <audio id="sound13" src="audio/cat.mp3"></audio> 
 
     <a onclick="document.getElementById('sound13').play(); showHide('Cat');"> 
 
     <img src="http://dummyimage.com/220x160?text=Cat" id="cat" alt="cat" width="220" height="160"> 
 
     </a> 
 
     <span id="img13"> </span> 
 
     <audio id="sound14" src="audio/dog.mp3"></audio> 
 
     <a onclick="document.getElementById('sound14').play();showHide('Dog');"> 
 
     <img src="http://dummyimage.com/220x160?text=Dog" id="dog" alt="dog" width="220" height="160"> 
 
     </a> 
 
     <span id="img14"> </span> 
 
     <br> 
 
     <audio id="sound15" src="audio/monkey.mp3"></audio> 
 
     <a onclick="document.getElementById('sound15').play();showHide('Monkey');"> 
 
     <img src="http://dummyimage.com/220x160?text=Monkey" id="monkey" alt="monkey" width="220" height="160"> 
 
     </a> 
 
     <span id="img15"> </span> 
 
     <audio id="sound16" src="audio/fox.mp3"></audio> 
 
     <a onclick="document.getElementById('sound16').play();showHide('Fox');"> 
 
     <img src="http://dummyimage.com/220x160?text=Fox" id="fox" alt="fox" width="220" height="160"> 
 
     </a> 
 
     <span id="img16"> </span> 
 
    </div> 
 
    </div> 
 

 
    <div class="responsive"> 
 
    <div class="img"> 
 
     <audio id="sound9" src="audio/window.mp3"></audio> 
 
     <a onclick="document.getElementById('sound9').play();showHide('Window');"> 
 
     <img src="http://dummyimage.com/220x160?text=Window" id="window" alt="window" width="220" height="160"> 
 
     </a> 
 
     <span id="img9"></span> 
 
     <audio id="sound10" src="audio/table.mp3"></audio> 
 
     <a onclick="document.getElementById('sound10').play(); showHide('Table');"> 
 
     <img src="http://dummyimage.com/220x160?text=Table" id="table" alt="table" width="220" height="160"> 
 
     </a> 
 
     <span id="img10"></span> 
 
     <br> 
 
     <audio id="sound11" src="audio/roof.mp3"></audio> 
 
     <a onclick="document.getElementById('sound11').play();showHide('Roof');"> 
 
     <img src="http://dummyimage.com/220x160?text=Roof" id="roof" alt="roof" width="220" height="160"> 
 
     </a> 
 
     <span id="img11"> </span> 
 
     <audio id="sound12" src="audio/floor.mp3"></audio> 
 
     <a onclick="document.getElementById('sound12').play();showHide('Floor'); "> 
 
     <img src="http://dummyimage.com/220x160?text=Floor" id="floor" alt="floor" width="220" height="160"> 
 
     </a> 
 
     <span id="img12"> </span> 
 
    </div> 
 
    </div> 
 
</div> 
 
<a href="first_page.html"> 
 
    <img class="arrow" src="http://dummyimage.com/220x200/FFD700/FF1493?text=arrow" alt="Arrow"> 
 
    </a> 
 
</div>

+0

對不起,我想說整個div來放置在中間 – chi