2016-09-13 74 views
1

我有一个由3列体组成的页面。第一列和第三列内有按钮。我试图正确定位它们。列内绝对位置

特别是,我有一个问题,必须显示在页面底部(靠近页脚)的第一列的按钮。

但我用的样式没有效果。我想这是因为列是空的,并且定位是相对于其高度而言的。我试图使用height:100%;属性,但它不起作用。

我该如何解决它?

 <!DOCTYPE html> 
    <html lang="en"> 
    <head> 
     <title>Bootstrap Example</title> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <link rel="stylesheet"          href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
     <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
<style> 
html { 
     position: relative; 
     min-height: 100%; 
     } 
body { 
     margin-bottom: 20vh; 
     background-color:#f2f2f2; 
     } 
     footer { 
      position: absolute; 
      bottom: 0; 
      width: 100%; 
      height: 10vh; 
     } 

     footer { 
      background-color: black; 
      color:white; 
      } </style> 
     <style> 
       #upButton {position:absolute; left:0px; bottom:0px;} 
     </style> 

     <style> 
       .col1 {height:100%;} 
     </style> 
</head> 
<body> 
      <div id="header" class="header" align="center"> 
          <h1 align="center">Some header 
          <small>some subheader</smalll> 
       </div>       
      <div class="container"> 
         <div class="row"> 
           <div class="col-md-2 col1"> 
                <a id="upButton" 
             href="#header" class="btn btn-success" 
             role="button">Up 
                </a> 
           </div> 
           <div class="col-md-8">...</div> 
           <div class="col-md-2"> 
            <a href="#f" align="right" class="btn 
           btn-danger" role="button">Down 
            </a> 
           </div> 
         </div> 
      </div> 
    <footer> 
     <div class="container-fluid"> 
      <p><a id="f">All right unreserved</a></p> 
     </div> 
     </footer> 
</body> 

所以现在我的解决办法只能如果我把大量文字的第一列里 - 然后向上按钮靠近页脚,因为它应该是。但没有文字它向上...

编辑:我设法解决它通过把两个按钮正确的身体,但如果有一个解决方案,允许他们留在各自的专栏,我想知道。 upbuttondownbutton 在图片上,向上按钮靠近页脚,而向下按钮靠近页眉。

编辑:有建议的解决方案代码:

 <!DOCTYPE html> 
    <html lang="en"> 
    <head> 
     <title>Bootstrap Example</title> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <link rel="stylesheet"          href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
     <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
<style> 
html { 
     position: relative; 
     min-height: 100%; 
     } 
body { 
     margin-bottom: 20vh; 
     background-color:#f2f2f2; 
     } 
     footer { 
      position: absolute; 
      bottom: 0; 
      width: 100%; 
      height: 10vh; 
     } 

     footer { 
      background-color: black; 
      color:white; 
      } </style> 


     <style> 
        #upButton {position:fixed; left:0px; bottom:100px;} 
        .col1 {height:100%;} 
     </style> 


</head> 
<body> 
      <div id="header" class="header" align="center"> 
          <h1 align="center">Some header 
          <small>some subheader</smalll> 
       </div>       
      <div class="container"> 
         <div class="row"> 
           <div class="col-md-2 col1"> 
                <a id="upButton" 
             href="#header" class="btn btn-success" 
             role="button">Up 
                </a> 
           </div> 
           <div class="col-md-8">.This book must have been revolutionary when it came out in the 1930s. The language, the style, the unbashed uncaring for literary norms must have been like a fresh air of rebellion to the stifled people of the 1930s who just few decades ago were under the moral oppression of the Victorian age. The book begins with an ode to Tanya's cunt. And it continues in the same manner. The word cunt is probably the most used word in the entire book. Today it would be called vulgar, but at the time it was revolutionary and brave. Miller describes multiple women he's had sex with while living in Paris, mostly on the money of other people, or as a vagrant and homeless on the streets. Most of the women he sleeps with are prostitutes (and he goes at length discussing the different types of prostitutes), but there is also the Jewish adulteress, the Russian princess with gonorrhea, the strange french woman to whom he gives 100 francs and then takes them out of her purse after having sex with her in her house above the room of her sick mother. Chapters of lucid description of characters (mostly Miller's friends whose money he uses, at whose houses he sleeps and whose women he has sex with) and some semblance of story lines are alternated with chapters of stream-of-consciousness monologues with prophetic statements and deep insights into life and living that usually come only after a very heavy intoxication with various substances. The book finishes in a middle of an action, just like it starts. Nothing really happens throughout and there's no sustained plot or even any novel-long characters (except the author-narrator) but it does give an entertaining and fascinating view into the life of the American emigres to Paris between the two wars in a much different way than Hemingway. POSTED BY MR.B. AT 2:12 PM NO COMMENTS: THURSDAY, JULY 7, 2016 "Mount Analogue" by Rene Daumal It ends in mid-sentence in the fifth chapter. Rene Daumal died days later of tubercolosis. He was in his 36th year of his life. Peradams. Only Father Sogol (Logos, took me a while to figure it out without anyone pointing it out to me) found one and very low, below the mountain where no Peradams are usually found, but he had an epiphany about himself. The book has an extensive intro section where the future planned chapters by Daumal are explained and it is a real shame that they were not written. Or maybe the book is more effective this way? After all Gurdjieff's "Life is real only when I AM" also stops in a middle of a sentence, and some who have seen the original manuscripts say that the published version is a much smaller selection from what was available. "Mount Analogue" is a very readable and well written book, to be expected from a writer of Daumal's caliber, and although Gurdjieff's name is never explicitly mentioned - it is based on the ideas and understanding of Gurdjieff's system (not to be called "The Fourth Way", but simply the "Gurdjieff System") and contains the personal thoughts and development of a person working on themselves according to the system. The explanation on how Mount Analogue This book must have been revolutionary when it came out in the 1930s. The language, the style, the unbashed uncaring for literary norms must have been like a fresh air of rebellion to the stifled people of the 1930s who just few decades ago were under the moral oppression of the Victorian age. The book begins with an ode to Tanya's cunt. And it continues in the same manner. The word cunt is probably the most used word in the entire book. Today it would be called vulgar, but at the time it was revolutionary and brave. Miller describes multiple women he's had sex with while living in Paris, mostly on the money of other people, or as a vagrant and homeless on the streets. Most of the women he sleeps with are prostitutes (and he goes at length discussing the different types of prostitutes), but there is also the Jewish adulteress, the Russian princess with gonorrhea, the strange french woman to whom he gives 100 francs and then takes them out of her purse after having sex with her in her house above the room of her sick mother. Chapters of lucid description of characters (mostly Miller's friends whose money he uses, at whose houses he sleeps and whose women he has sex with) and some semblance of story lines are alternated with chapters of stream-of-consciousness monologues with prophetic statements and deep insights into life and living that usually come only after a very heavy intoxication with various substances. The book finishes in a middle of an action, just like it starts. Nothing really happens throughout and there's no sustained plot or even any novel-long characters (except the author-narrator) but it does give an entertaining and fascinating view into the life of the American emigres to Paris between the two wars in a much different way than Hemingway. POSTED BY MR.B. AT 2:12 PM NO COMMENTS: THURSDAY, JULY 7, 2016 "Mount Analogue" by Rene Daumal It ends in mid-sentence in the fifth chapter. Rene Daumal died days later of tubercolosis. He was in his 36th year of his life. Peradams. Only Father Sogol (Logos, took me a while to figure it out without anyone pointing it out to me) found one and very low, below the mountain where no Peradams are usually found, but he had an epiphany about himself. The book has an extensive intro section where the future planned chapters by Daumal are explained and it is a real shame that they were not written. Or maybe the book is more effective this way? After all Gurdjieff's "Life is real only when I AM" also stops in a middle of a sentence, and some who have seen the original manuscripts say that the published version is a much smaller selection from what was available. "Mount Analogue" is a very readable and well written book, to be expected from a writer of Daumal's caliber, and although Gurdjieff's name is never explicitly mentioned - it is based on the ideas and understanding of Gurdjieff's system (not to be called "The Fourth Way", but simply the "Gurdjieff System") and contains the personal thoughts and development of a person working on themselves according to the system. The explanation on how Mount Analogue would have been physically hidden from anyone for so long is definitely done by the latest science available at that period (1930s), but with today's satellites and space observation does not hold well at all, although it was probably ingenious for the time. Also getting there, getting in and discovering no new technology (based on electricity) works on the mountain is also very interesting, especially connected to Gurdjieff's notion that electricity was discovered before and is not an inexhaustible resource. Of course, Father Sogol is no one but Alexandre de (von) Saltzmann, one of the foremost Gurdjieff's students, of whom not as much is known, compared to the other students like Alexandre's wife Jeanne, and the de (von) Hartmann's. He must have been a formidable personality to have left such an impression on Daumal. This book is a gem, even in its unfinished form, or maybe because of it.This book must have been revolutionary when it came out in the 1930s. The language, the style, the unbashed uncaring for literary norms must have been like a fresh air of rebellion to the stifled people of the 1930s who just few decades ago were under the moral oppression of the Victorian age. The book begins with an ode to Tanya's cunt. And it continues in the same manner. The word cunt is probably the most used word in the entire book. Today it would be called vulgar, but at the time it was revolutionary and brave. Miller describes multiple women he's had sex with while living in Paris, mostly on the money of other people, or as a vagrant and homeless on the streets. Most of the women he sleeps with are prostitutes (and he goes at length discussing the different types of prostitutes), but there is also the Jewish adulteress, the Russian princess with gonorrhea, the strange french woman to whom he gives 100 francs and then takes them out of her purse after having sex with her in her house above the room of her sick mother. Chapters of lucid description of characters (mostly Miller's friends whose money he uses, at whose houses he sleeps and whose women he has sex with) and some semblance of story lines are alternated with chapters of stream-of-consciousness monologues with prophetic statements and deep insights into life and living that usually come only after a very heavy intoxication with various substances. The book finishes in a middle of an action, just like it starts. Nothing really happens throughout and there's no sustained plot or even any novel-long characters (except the author-narrator) but it does give an entertaining and fascinating view into the life of the American emigres to Paris between the two wars in a much different way than Hemingway. POSTED BY MR.B. AT 2:12 PM NO COMMENTS: THURSDAY, JULY 7, 2016 "Mount Analogue" by Rene Daumal It ends in mid-sentence in the fifth chapter. Rene Daumal died days later of tubercolosis. He was in his 36th year of his life. Peradams. Only Father Sogol (Logos, took me a while to figure it out without anyone pointing it out to me) found one and very low, below the mountain where no Peradams are usually found, but he had an epiphany about himself. The book has an extensive intro section where the future planned chapters by Daumal are explained and it is a real shame that they were not written. Or maybe the book is more effective this way? After all Gurdjieff's "Life is real only when I AM" also stops in a middle of a sentence, and some who have seen the original manuscripts say that the published version is a much smaller selection from what was available. "Mount Analogue" is a very readable and well written book, to be expected from a writer of Daumal's caliber, and although Gurdjieff's name is never explicitly mentioned - it is based on the ideas and understanding of Gurdjieff's system (not to be called "The Fourth Way", but simply the "Gurdjieff System") and contains the personal thoughts and development of a person working on themselves according to the system. The explanation on how Mount Analogue would have been physically hidden from anyone for so long is definitely done by the latest science available at that period (1930s), but with today's satellites and space observation does not hold well at all, although it was probably ingenious for the time. Also getting there, getting in and discovering no new technology (based on electricity) works on the mountain is also very interesting, especially connected to Gurdjieff's notion that electricity was discovered before and is not an inexhaustible resource. Of course, Father Sogol is no one but Alexandre de (von) Saltzmann, one of the foremost Gurdjieff's students, of whom not as much is known, compared to the other students like Alexandre's wife Jeanne, and the de (von) Hartmann's. He must have been a formidable personality to have left such an impression on Daumal. This book is a gem, even in its unfinished form, or maybe because of it.This book must have been revolutionary when it came out in the 1930s. The language, the style, the unbashed uncaring for literary norms must have been like a fresh air of rebellion to the stifled people of the 1930s who just few decades ago were under the moral oppression of the Victorian age. The book begins with an ode to Tanya's cunt. And it continues in the same manner. The word cunt is probably the most used word in the entire book. Today it would be called vulgar, but at the time it was revolutionary and brave. Miller describes multiple women he's had sex with while living in Paris, mostly on the money of other people, or as a vagrant and homeless on the streets. Most of the women he sleeps with are prostitutes (and he goes at length discussing the different types of prostitutes), but there is also the Jewish adulteress, the Russian princess with gonorrhea, the strange french woman to whom he gives 100 francs and then takes them out of her purse after having sex with her in her house above the room of her sick mother. Chapters of lucid description of characters (mostly Miller's friends whose money he uses, at whose houses he sleeps and whose women he has sex with) and some semblance of story lines are alternated with chapters of stream-of-consciousness monologues with prophetic statements and deep insights into life and living that usually come only after a very heavy intoxication with various substances. The book finishes in a middle of an action, just like it starts. Nothing really happens throughout and there's no sustained plot or even any novel-long characters (except the author-narrator) but it does give an entertaining and fascinating view into the life of the American emigres to Paris between the two wars in a much different way than Hemingway. POSTED BY MR.B. AT 2:12 PM NO COMMENTS: THURSDAY, JULY 7, 2016 "Mount Analogue" by Rene Daumal It ends in mid-sentence in the fifth chapter. Rene Daumal died days later of tubercolosis. He was in his 36th year of his life. Peradams. Only Father Sogol (Logos, took me a while to figure it out without anyone pointing it out to me) found one and very low, below the mountain where no Peradams are usually found, but he had an epiphany about himself. The book has an extensive intro section where the future planned chapters by Daumal are explained and it is a real shame that they were not written. Or maybe the book is more effective this way? After all Gurdjieff's "Life is real only when I AM" also stops in a middle of a sentence, and some who have seen the original manuscripts say that the published version is a much smaller selection from what was available. "Mount Analogue" is a very readable and well written book, to be expected from a writer of Daumal's caliber, and although Gurdjieff's name is never explicitly mentioned - it is based on the ideas and understanding of Gurdjieff's system (not to be called "The Fourth Way", but simply the "Gurdjieff System") and contains the personal thoughts and development of a person working on themselves according to the system. The explanation on how Mount Analogue would have been physically hidden from anyone for so long is definitely done by the latest science available at that period (1930s), but ..</div> 
           <div class="col-md-2"> 
            <a href="#f" align="right" class="btn 
           btn-danger" role="button">Down 
            </a> 
           </div> 
         </div> 
      </div> 
    <footer> 
     <div class="container-fluid"> 
      <p><a id="f">All right unreserved</a></p> 
     </div> 
     </footer> 
</body> 
</html> 
+1

你能提供一个你想要的样子吗?一个图像将不胜感激。 – netto

+0

查看我的回答...我认为您正在制作导航按钮以进入您的页面,我的解决方案堆叠在您的视口的底部,因此如果您需要一些保证金,请添加margin-bottom:{height页脚} px; ... – netto

回答

1

尝试自己的风格改变了这一点。输出可能是你寻找的结果。

<style> 
    #upButton {position:fixed; left:0px; bottom:0px;} 
    .col1 {height:100%;} 
</style> 

我换了个姿势,从绝对固定,尝试读取位置不同的价值观...... CSS Layout - The position Property

+0

谢谢,这几乎和预期的一样。但是,是否可以让“向上”按钮保持在底部,这样当我看不到页脚时,我看不到按钮? – parsecer

+0

hm ...可以传递你的页面的整个代码?所以我可以尝试修复它? – netto

+0

当然。编辑帖子,查看最后一个代码块。尝试使用此网站http://www.w3schools.com/html/tryit.asp?filename=tryhtml_default,它会正确显示代码。 – parsecer

1

使得upButton固定的,我们可以不考虑控制它的它的父所以这样我们就可以实现您的要求

<head> 
    <style> 
      #upButton {position:fixed; left:5px; bottom:5px;} 
      .col1 { height:100%; } 
    </style> 
    </head> 
    <body> 

     <div class="container-fluid"> 
        <div class="row" style="height: 100%"> 
          <div class="col-xs-2 col1"> 
           <a id="upButton" href="#header" class="btn btn-success" role="button">Up 
           </a> 
          </div> 
          <div class="col-xs-8">.......</div> 
          <div class="col-xs-2"> 
           <a href="#f" align="right" class="btn btn-danger" role="button">Down 
           </a> 
          </div> 
        </div> 
      </div> 

</body> 

现场演示:https://jsbin.com/kuberop/2/edit?html,output

2

一种方法,我建议是,你使用flex

首先确保bodycontainerrowcol1所有占用全高甚至是空的时,(检查确认)。

如果是,则将col1设置为display:flex。你可以很容易地使用flex儿童的特性来使它保持下来。

#upButton { 
align-self: flex-end 
} 
+0

我会用这个,flex box是一个不错的选择,支持非常广泛:http://caniuse.com/#feat=flexbox – kaosmos