【问题标题】:Vertical align text with icon with shaded box and corner on top only仅将文本与带有阴影框和角的图标垂直对齐
【发布时间】:2012-10-30 20:25:21
【问题描述】:

我已经创建了一个按钮,HTML 如下所示:

<div class="blue_text"><button class="blue_small" id="blue_small"></button> View this video instead.</div>

CSS 如下。文本垂直对齐而不改变现有标记:

#blue_text{ color:#48c4d2; font-size:15px; font-family:opensansitalic;}

用于垂直对齐按钮而不更改现有标记。

​button {
vertical-align:middle;
}

按钮CSS总数:

.blue_small {
 height: 40px;
width: 40px;
margin-left:16px;
margin-bottom:1px;
background-color:#fff;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
border: 3px solid #fff;
background:url(../images/index_video_small2.svg) no-repeat 5px 7px;
-webkit-box-shadow: 0px 2px 6px rgba(64,80,85,0.8);  
-moz-box-shadow: 0px 2px 6px rgba(64,80,85,0.8);
box-shadow: 0px 2px 6px rgba(64,80,85,0.8);
color:#48c4d2; font-size:15px;
    font-family:opensansitalic;}

我想将以上所有内容结合到 CSS 中,如下所示,并带有青色阴影框?我从来没有试过这个。

align top http://www.kerrydeaf.com/shade2.png

更新:我在另一个容器的底部有这个 div >,但是有可见的间隙并试图缩小间隙但没有成功?我正在使用当前的 div >,如下所示。

<div class="blue_text"><button class="blue_small" id="blue_small"></button> View this video instead.</div>

这是一个可见的间隙,如下所示:

align top http://www.kerrydeaf.com/shade4.png

我希望用这个 查看这个视频来代替。

用边距“0”来缩小差距,如下所示。

align top http://www.kerrydeaf.com/shade3.png

周五下午 2 点更新:谢谢,它很有效。它转到浏览器窗口的底部。我希望蓝色框关闭在 DIV 标签之间,例如下面的这个 DIV 标签。这个 div class="toogle_wrap" 是一个 DIV 容器,我在其中突出显示了要关闭的间隙,如下所示。将至少有五个 div class="toogle_wrap",这是一个 div class="toogle_wrap",因此需要将每个差距缩小。 p>

      <div class="toogle_wrap">
    <div class="trigger"><a href="#"><span class="trig">1.</span> Deaf person's attention</a></div>
    <div class="toggle_container"> 
    <ul class="lists">
    <li>Learn <span class="bold">how to get</span> a Deaf person's attention.</li>
    <li>Take a step-by-step process.</li>
    <li>Approaching a Deaf and your approach may suggest your intention to communicate.</li>
    <li>You can also <span class="bold">wave</span> to get eye contact or <span class="bold">tap</span> the person gently on the shoulder.</li>
    <!--<li><span class="bold">Watch a video instead:</span> <span class="typicons">Z</span>  <span class="typicn"<h5>Z</h5></span> </li>-->
    </ul>
    <div class="blue_text"><button class="blue_small" id="blue_small"></button> Available in video.</div>
            <<<<<<<<<< The gap is here to close here >>>>>>>>.
            <<<<<<<<<< The gap is here to close here >>>>>>>>.
            <<<<<<<<<< The gap is here to close here >>>>>>>>.
            <<<<<<<<<< The gap is here to close here >>>>>>>>.
            <<<<<<<<<< The gap is here to close here >>>>>>>>.
    </div>
  </div>

周五晚上 10 点更新。这是 DIV 的示例。 position: relative应该进入哪个DIV?

align top http://www.kerrydeaf.com/div.png

标签: html css


【解决方案1】:

在此处查看我的工作示例:http://jsfiddle.net/2x6ub/3/

div.toggle_container { 
   position: relative;  // this makes the blue_text div being able to align to bottom
   border: 1px solid #000; height: 300px; // this is just to test, remove or adjust
}

.blue_text{ 
    background:#48c4d2; 
    color:#fff; 
    font-size:20px; 
    font-family:opensansitalic; 
    width:400px; 
    font-style:italic; 
    padding:20px; 
    border-top-left-radius:20px;
    border-top-right-radius:20px;
    -moz-border-top-left-radius:20px;
    -moz-border-top-right-radius:20px;
    -webkit-border-top-left-radius:20px;
    -webkit-border-top-right-radius:20px;

    /* to align to bottom of parent container */
    position: absolute; 
    bottom: 0px;

 }

【讨论】:

  • @Irishgirl 另请注意您在上面发布的 css 是错误的 #blue_text 是您使用的 ID class="blue_text" 所以我的 css 我使用了 .blue_text
  • 如果您不介意,您能否解决这个问题,因为我的图标没有按应有的方式显示?
  • @Irishgirl 我没有文件 (../images/index_video_small2.svg) 所以你需要把你自己的路径放在这里。不会变魔术!
  • 更新:是否有可能让这个 div > 在底部零边距处没有任何间隙。我试过了,但没有成功?
  • 我已更新我的请求以缩小 div 内的差距。也许我没有说清楚。你所做的也很有效,它进入了浏览器窗口的底部。相反,我在上面有一个 DIV 标记示例来向您展示应该在哪里关闭间隙。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-28
相关资源
最近更新 更多