文字

时间:2017-08-28 06:39:23

标签: html css

我尝试过以下代码来获取所需的输出,如何在其中间显示该锁定。

我尝试了很多东西,我在SO上找到了,但没有任何帮助。 我对CSS不是很有经验。

我想这样显示:

enter image description here

.inline-block {
  display: inline-block;
}

.lock_image {
  width: 30px;
  height: 30px;
}

hr {
  width: 250px;
  margin: 0px;
  bottom: 1px;
  margin-bottom: 5px !important;
  margin-top: 5px !important;
}

.title {
  margin: 0px;
}
<div class="inline-block"><img src="https://image.ibb.co/f7sA2Q/icons8_Lock_50.png" alt="icons8_Lock_50" border="0" class="lock_image"></div>
<div class="inline-block">
  <p class="title">Google Drive Integrated Email</p>
  <hr>
  <a class="mgl20" href="javascript:void(0);">xyz@gmail.com</a>
</div>

3 个答案:

答案 0 :(得分:1)

请在vertical-align:middle课程中添加inline-block

.inline-block{
  display:inline-block;
  vertical-align:middle;
}

.lock_image{
  width:30px;
  height:30px;
}

hr{
  width: 250px;
  margin: 0px;
  bottom: 1px;
  margin-bottom: 5px !important;
  margin-top: 5px !important;
}

.title{
  margin:0px;
}
<div class="inline-block"><img src="https://image.ibb.co/f7sA2Q/icons8_Lock_50.png" alt="icons8_Lock_50" border="0" class="lock_image"></div>
<div class="inline-block"><p class="title">Google Drive Integrated Email</p><hr>
    <a class="mgl20" href="javascript:void(0);">xyz@gmail.com</a>
</div>

答案 1 :(得分:1)

我在你的内容周围添加了一个包装器,并将其设为flexbox,垂直居中对齐。

.wrapper {
  display: flex;
  align-items: center;
}

.inline-block {
  display: inline-block;
}

.lock_image {
  width: 30px;
  height: 30px;
}

hr {
  width: 250px;
  margin: 0px;
  bottom: 1px;
  margin-bottom: 5px !important;
  margin-top: 5px !important;
}

.title {
  margin: 0px;
}
<div class="wrapper">
  <div class="inline-block">
    <img src="https://image.ibb.co/f7sA2Q/icons8_Lock_50.png" alt="icons8_Lock_50" border="0" class="lock_image">
  </div>
  <div class="inline-block">
    <p class="title">Google Drive Integrated Email</p>
    <hr>
    <a class="mgl20" href="javascript:void(0);">xyz@gmail.com</a>
  </div>
</div>

答案 2 :(得分:0)

试试这段代码: 这是jsfiddle:https://jsfiddle.net/rhulkashyap/71a9uLvy/

.inline-block{
  display:inline-block;
  vertical-align:middle;
}

.lock_image{
  width:30px;
  height:30px;
}

hr{
  width: 250px;
  margin: 0px;
  bottom: 1px;
  margin-bottom: 5px !important;
  margin-top: 5px !important;
}

.title{
  margin:0px;
}
<div class="inline-block"><img src="https://cdn.pbrd.co/images/GHHKwv7.png" alt="icons8_Lock_50" border="0" class="lock_image"></div>
<div class="inline-block"><p class="title">Google Drive Integrated Email</p><hr>
    <a class="mgl20" href="javascript:void(0);">xyz@gmail.com</a>
</div>