用于显示内联的CSS样式

时间:2015-03-07 05:19:53

标签: html css html5 css3

我想在同一行显示<h1>代码和button代码,但button略低于h1{ display:inline-block; } .log { width:60%; height: 30%; position: absolute; border: 1px solid #f9f2f2; border-radius: 10px; background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff)); background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%); filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff"); background: -o-linear-gradient(top, #e5e3e3, ffffff); background-color: #e5e3e3; border: 0px solid #f9f2f2; text-align: center; line-height:20px; border-width: 0px 0px 1px 1px; }。我在绿色标记我要显示它:

enter image description here

<div class="log">
    <h1>Profile</h1>
    <form method="post"> 
        <button class="logout" name="logout" >Logout</button>
    </form>      
</div> 
{{1}}

3 个答案:

答案 0 :(得分:1)

我刚修改过这个:

form {
    float: right;
    display: inline-block;
    margin-top: 20px;
}

&#13;
&#13;
h1 {
  display: inline-block;
}
.log {
  width: 60%;
  height: 30%;
  position: absolute;
  border: 1px solid #f9f2f2;
  border-radius: 10px;
  background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
  background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
  filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
  background: -o-linear-gradient(top, #e5e3e3, ffffff);
  background-color: #e5e3e3;
  border: 0px solid #f9f2f2;
  text-align: center;
  line-height: 20px;
  border-width: 0px 0px 1px 1px;
}
form {
  float: right;
  display: inline-block;
  margin-top: 20px;
}
&#13;
<div class="log">
  <h1>Profile</h1>
  <form method="post">
    <button class="logout" name="logout">Logout</button>
  </form>

</div>
<!--End of log div -->
&#13;
&#13;
&#13;

或者你可以用:

form{
    display:inline; 
}

答案 1 :(得分:0)

您有<h1>代码的内嵌,现在您可以将内联插入form代码中,如下所示:

<form method="post" style="display:inline"> 
     <button class="logout" name="logout" >Logout</button>
</form>

答案 2 :(得分:0)

&#13;
&#13;
h1{
    display:inline-block; 
}

.log {
    width:60%;
    height: 30%;
    position: absolute;
    border: 1px solid #f9f2f2;
    border-radius: 10px;
    background: -o-linear-gradient(bottom, #e5e3e3 5%, #ffffff 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e5e3e3), color-stop(1, #ffffff));
    background: -moz-linear-gradient(center top, #e5e3e3 5%, #ffffff 100%);
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#e5e3e3", endColorstr="#ffffff");
    background: -o-linear-gradient(top, #e5e3e3, ffffff);
    background-color: #e5e3e3;
    border: 0px solid #f9f2f2;
    text-align: center;
    line-height:20px;
    border-width: 0px 0px 1px 1px;
}
form{
display:inline-block;
float:right;
  margin-top:20px;
  
}
&#13;
<div class="log">
    <h1>Profile</h1>
    <form method="post"> 
        <button class="logout" name="logout" >Logout</button>
    </form>      
</div> 
&#13;
&#13;
&#13;