2017-02-11 35 views
2

這裏是我的代碼,我想通過在兩個div之間添加hr來分隔2個div,任何人都可以幫助我添加一個小時,它將擴展到整個線以下的介紹和圖片介紹,作爲HR只延長到介紹的形象,所以任何人都可以幫助我的HR-我無法添加延伸到整個行下面的小時

#intro{ 
     font-family: 'Sansita', sans-serif; 
     font-size: 170%;  
     float: right;     
     width: 50%;     
     margin-right: 20px; 
     margin-left: 10px; 
      color: #ff471a ; 
     } 



     #introImage { 

      float: left; 
      width: 40%; 
      margin-left: 70px; 
      margin-top: 35px; 
      box-shadow: 10px 10px grey; 
      border-radius: 10px; 

     } 




    #hitchhiking-info { 

     margin-top: 20px; 
     width: 100%; 
     height: 100px; 
     text-align: center; 
     background-color: blue; 
     float: none; 

    } 

<div id="intro-div"> 

     <p id="intro"> Hello There! I have made this website to share my experiences of hitchhiking, which is my full time job. I want to inspire other hitchhikers as well and inspire people. This website will hopefully clear all your misconceptions about hitchhiking as a proffession, as it is underrated and critisized by people. However I have a very different perspective about hitchhiking, you will get to know about it through my website. This website is a mean I will be using to reach to people around the world. Fell free to comment any suggestions or feedback of my experiences and contact me for any query </p>  

     <img id="introImage" src="intro-image.jpg"> 




    </div> 

    <div id="hitchhiking-info"> 

     <h1 id="heading"> Hitchhiking </h1> 
    </div> 

This is the layout of my page

+0

發佈當前設計 – affaz

+0

截圖斷章取義的:請注意你的文字錯字:‘這一定是’「下跌免費...感覺免費...「(最後一句) – Arendax

+0

謝謝Arendax –

回答

2

重要的是要補充一點:

#intro-div { 
    overflow: auto; 
} 

任何容器,它僅包含浮動的Elemen ts將有0高度。爲避免這種情況,您必須將overflow: auto;overflow: hidden添加到其CSS。

在這裏看到的結果:

http://codepen.io/anon/pen/MJzdda

+0

非常感謝,它的工作! –

0

添加標籤小時之間你div的,然後在你的CSS文件,玩的小時標記

hr { 
display: block; 
margin-top: 0.5em; 
margin-bottom: 0.5em; 
margin-left: auto; 
margin-right: auto; 
border-style: inset; 
border-width: 1px; 
} 

玩同裕右和利潤率左屬性調整線的長度的CSS。

+0

感謝您的回答,但它不起作用 –

1

enter image description hereenter image description here
enter image description here

剛剛添加<hr/>和它的作品

<div id="intro-div"> 

     <p id="intro"> However I have a very different perspective about hitchhiking, you will get to know about it through my website. This website is a mean I will be using to reach to people around the world. Fell free to comment any suggestions or feedback of my experiences and contact me for any query </p>  

     <img id="introImage" src="intro-image.jpg"> 


<hr/> 

    </div> 

    <div id="hitchhiking-info"> 

     <h1 id="heading"> Hitchhiking </h1> 
    </div> 


    [1]: https://i.stack.imgur.com/wbY63.png 
+0

實際上我是一名學生,並且我被分配了一個問題來爲搭便車創建一個網站,所以對我而言,誠實,我不太瞭解 –

+1

hr {margin-left:-8px;}在css中添加它現在看起來像這樣 – varunkumar

+0

我已將元素對齊非常不同的方式,請親切看看它的css –