1

このようなものを作りたいと思っています。
ここに画像の説明を入力

見出しのような幅の線しか作成できないので、本当に疲れました。見出しよりも「小さい」行を作成する必要があります。::before で試してみましたが、うまくいきません。それを作成する可能な方法はありますか?

<h1>Some heading here</h1>

http://jsfiddle.net/53zxor2k/

4

3 に答える 3

3
h1 {
  display: inline-block;
  position: relative;
}
h1::after {
  content: '';
  position: absolute;
  left: 10%;
  display: inline-block;
  height: 1em;
  width: 70%;
  border-bottom: 1px solid;
  margin-top: 5px;
}

幅を希望の長さに変更し、「左」を行の位置に変更し、「マージントップ」を増やしてテキストから遠ざけます。

http://jsfiddle.net/53zxor2k/1/

于 2015-02-11T19:41:25.183 に答える
1

h1 { 
    position: relative;
    text-align: center
}

h1:before{
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 130px;
    height: 2px;
    background: red;
    transform:translateX(-65px) /*    width/2    */
}
    
    
<h1>some heading here</h1>

于 2015-02-11T19:36:17.800 に答える
0
<h1>some <span style="border-bottom: 2px solid red;">heading</span> here</h1>

それがあなたがやろうとしていることであれば、特定の単語の下に単に境界線を置くことができます.

于 2015-02-11T19:39:16.007 に答える