2017-01-19 9 views
-3

これは私が達成しようとしているものです:修正ステップライン応答CSS

enter image description here

これは私のコードを生成するものである:

enter image description here

.line { 
    position: relative; 
    background-color: #f1f1f1; 
    width: 34%; 
    height: 2px; 
    bottom: 36px; 
    left: 33%; 
} 

どのように私は調整することができますこの行を反応させるコードですか?ストライプは、モバイルでの33%の中心部(行全体の90%)にすることはできませんので

+0

CSS3 Media Queriesを使用 – GibboK

+0

あなたの現在のコードで[MCVE]を作ってください – Pete

答えて

-1

あなたは、携帯電話にmediaqueriesを追加することができます

0
.line 
{ 
    z-index:5; 
    position: relative; 
    background-color: #f1f1f1; 
    width: 34%; 
    height: 2px; 
    bottom: 36px; 
    left: 33%; 
} 
.yourcircle class 
{ 
    z-index:4; 
} 
0

デモ:https://jsfiddle.net/kc1tbu8x/2/

HTML:

<div class="wrapper"> 
<div class="step1"> 
    <hr/> 
</div> 

<div class="step2"> 
    <div class="step2_circles">1</div> 
    <div class="step2_circles">2</div> 
    <div class="step2_circles">3</div> 
</div> 
</div> 

CSS:

.wrapper{ 
    width:30%; 
    height:40px; 
    display:block; 
    position:relative; 
} 
.step1{ 
    width:98%; 
    z-index:-9999; 
    position:absolute; 
    top:25%; 
    display:block; 
    margin:auto; 

} 
.step2{ 
    width:100%; 
    display:flex; 
    display:-webkit-flex; 
    -webkit-justify-content: space-between; 
    justify-content: space-between; 
} 
.step2_circles{ 
    width:40px; 
    height:40px; 
    border-radius: 50%; 
    -moz-border-radius: 50%; 
    -o-border-radius: 50%; 
    -webkit-border-radius: 50%; 
    -ms-border-radius: 50%; 
    background:#ff0000; 
    text-align:center; 
    line-height:40px; 

} 

デモ:https://jsfiddle.net/kc1tbu8x/2/

0

これ以外の方法もありますが、上記のフレックスボックスソリューションは良いと思います。 デモ:http://codepen.io/anon/pen/XppLjW

HTML:

<div class="steps"> 
    <span>1</span> 
    <span>2</span> 
    <span>3</span> 
</div> 

CSS:

.steps { 
    width: 100%; 
    height: 80px; 
    max-width: 80%; 
    margin: 3em auto; 
    text-align: center; 
    position: relative; 
} 
.steps::before { 
    left: 0; 
    top: 50%; 
    content: ''; 
    width: 100%; 
    height: 1px; 
    display: block; 
    position: absolute; 
    background-color: #e5e5e5; 
} 
.steps span { 
    width: 80px; 
    height: 80px; 
    line-height: 80px; 
    border-radius: 50%; 
    text-align: center; 
    position: absolute; 
    display: inline-block; 
    background-color: #d4d4d4; 
} 
.steps span:first-child { 
    left: 0; 
} 
.steps span:nth-child(2) { 
    left: 50%; 
    -webkit-transform: translateX(-50%); 
    transform: translateX(-50%); 
} 
.steps span:last-child { 
    right: 0; 
} 
0

てみてください、それは

<div class="container"> 
    <div class="number">1</div> 
    <div class="number">2</div> 
    <div class="number">3</div> 
</div> 

.container { 
    display: flex; 
    justify-content: space-between; 
    position: relative; 
} 

.container:before { 
    content: ''; 
    display: block; 
    height: 2px; 
    width: 100%; 
    position: absolute; 
    top: 50%; 
    margin-top: -1px; 
    background:red; 
} 

.container .number { 
    width: 20px; 
    height: 20px; 
    border-radius: 50%; 
    background: blue; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    position: relative; 
    z-index: 10; 
} 

良い例だJSfiddle例https://jsfiddle.net/4j07gbrd/