在标题和段落周围放置一个边框

时间:2016-06-14 15:05:32

标签: html css

我试图在标题和段落周围放置一个边框。目前我在标题和段落周围有两个单独的边框。我怎样才能在它们周围放一个边框?

<style type="text/css">
h1{
 font-family: consolas;
border: 2px solid #73AD21;
border-radius: 25px;

}
p{
font-family: Consolas;
border: 2px solid #73AD21;
border-radius: 25px;

}
</style>

<h1>Hello</h1>
<p>World</p>

3 个答案:

答案 0 :(得分:2)

就像上面提到的Harry一样,只需将它们添加到包装器中,然后在包装器上设置样式。像这样:

&#13;
&#13;
private List<string> GetInstalledSoftware(string regKey)
{
    var installedSoftware = new List<string>();

    using (RegistryKey key = Registry.LocalMachine.OpenSubKey(regKey))
    {
        if (key != null)
        {
            foreach (string subkey_name in key.GetSubKeyNames())
            {
                using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                {
                    object displayName = subkey.GetValue(ToolResources.DisplayName);

                    if (displayName != null)
                    {
                        installedSoftware.Add(displayName.ToString());
                    }
                }
           }
       }
    }

    return installedSoftware;
}
&#13;
    if (!bool1 && !bool2) {
        // throw error for bool1 && bool2 failing
    } else if (!bool1) {
        // throw error for bool1 failing
    } else {
        // throw error for bool2 failing
    }
&#13;
&#13;
&#13;

或者,如果您不能或不想更改标记,只需删除 public function checkCodeRespondent() { $password = $this->data['Respondent']['pass']; $condition = array('Respondent.pass'=>$password); if($this->Respondent->hasAny($condition)){ print 'password is correct'; } else { print 'password is not correct'; } } 元素的左下角div { font-family: consolas; border: 2px solid #73AD21; border-radius: 25px; }<div> <h1>Hello</h1> <p>World</p> </div>左下角,同时删除border元素的左上角和右上角border-radius以及h1。这也将产生您正在寻找的外观。

&#13;
&#13;
border
&#13;
border-radius
&#13;
&#13;
&#13;

答案 1 :(得分:0)

或者 - 如果你不能放一个包装器,就这样做:

h1 {
  font-family: consolas;
  border: 2px solid #73AD21;
  border-radius: 25px;
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
  padding: 10px;
}

p {
  font-family: Consolas;
  border: 2px solid #73AD21;
  border-radius: 25px;
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
  padding: 10px;
}

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

答案 2 :(得分:0)

&#13;
&#13;
h1{
 font-family: consolas;
}
p{
font-family: Consolas;
}
.wrapper{
 border: 2px solid #73AD21;
border-radius: 25px;
padding-left: 15px;
padding-right: 15px;
}
&#13;
<div class="wrapper">
<h1>Hello</h1>
<p>World</p>
</div>
&#13;
&#13;
&#13;

将两个标签放在包装器下并给出预期的边框。请查看以下内容: 的 CSS:

<style type="text/css">
h1{
 font-family: consolas;
}
p{
font-family: Consolas;
}
.wrapper{
border: 2px solid #73AD21;
border-radius: 25px;
padding-left: 15px;
padding-right: 15px;
}
</style>

<强> HTML:

<div class="wrapper">
<h1>Hello</h1>
<p>World</p>
</div>