0

リンクタグ内にアイコンがあり、それを円形にしようとしていますが、幅と高さの設定ではなく、コンテンツにフィットします。これが私が言いたいことです:http://i.imgur.com/q4GXvOs.png

私のコードは次のようなものです:

html:

<div class="small-4 columns switchButton">
    <a href="#">
        <i class="icon-bolt"></i>
    </a>
</div>

そして私のCSSは次のようなものです:

.switchButton
    text-align: center
    margin: 60px 0 60px 0
.switchButton a
    text-decoration: none
    width: 80px
    height: 80px
    font-size: 40px
    padding: 20px
    -moz-border-radius: 40px
    -webkit-border-radius: 40px
    border-radius: 40px

アイコンは font-awesome によるもので、次の CSS があります。

a [class^="icon-"], a [class*=" icon-"] {
display: inline;
}
[class^="icon-"], [class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: normal;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
margin-top: 0;
}
[class^="icon-"], [class*=" icon-"] {
font-family: FontAwesome;
font-weight: normal;
font-style: normal;
text-decoration: inherit;
-webkit-font-smoothing: antialiased;

そのため、幅と高さが設定されていても、アイコンに収まります。何か案は?

関連する JSFiddle: http://jsfiddle.net/babaggeii/QZSwn/2/ - タグが、指定された寸法ではなくテキストに適合していることがわかります。

4

1 に答える 1

1

あなたのものではないようですa60pxx87pxがあり、CSS に入力したものと一致しません。

これを試して:

.switchButton a {
    text-decoration: none;
    width: 80px;
    height: 80px;
    background-color: #666;
    color: #fff;
    font-size: 40px;
    -moz-border-radius: 40px;
    -webkit-border-radius: 40px;
    border-radius: 40px;

    /** My CSS **/
    display: block; /* The element is displayed as a block-level element (like paragraphs and headers) */
    line-height: 80px; /* To determine the height of your line */
    text-align: center; /* To centralize the text horizontally */
}

上記のコードはJSFiddleで説明しました。

それが役に立てば幸い。

于 2013-06-14T11:41:17.080 に答える