簡體   English   中英

是否可以輸入CSS邊框

[英]Is it possible to type in a CSS border

我目前正在建立一個網站,但遇到了問題。 在我的CSS代碼中,我有一些社交圖標左側的邊框。 它在我的社交內容旁邊有一個50像素的框。

我可以在50px邊框框中輸入文字嗎? 我想使用一種在字體內具有圖標的外部字體,並在邊框框中使用它們

CSS:

google {
border-left: 50px solid #db4a39;
color: #db4a39;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;

}

如果我無法輸入文字,有人可以為我建議其他選擇嗎?

在當前邊框的左側創建一個50px寬的<div>而不是邊框​​,是一個很好的解決方案: http : //jsfiddle.net/KzMKB/

編輯:我對額外的<div>動機是,我認為這種東西屬於子元素,而不是鞋角。 從語義上講,這很容易,只要將想要的任何內容放入<div>

如果您無法控制標記,則可以在偽元素之前使用:before。

刪除原始元素的border ,並將margin-left設置為50px;

google {
    margin-left:50px;
    color: #db4a39;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    transition: all 0.5s ease;
}
google:before {
    content: "hello";
    margin-left:-50px;
    background-color: #db4a39;
    color: black;
    display: block;
    width:50px;
    height:100%;
}

查看完整示例:

http://jsfiddle.net/6zX8y/1/

您可以使用text-indent屬性將文本移到邊框中。

#border-box {
  text-indent:-10px;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM