Как создать горизонтальную линию с точками над ней - PullRequest
0 голосов
/ 13 мая 2019

Я делаю школьный проект, в котором мне нужно создать горизонтальную линию с несколькими точками над ней.

Я не могу использовать css как отдельный файл.CSS должен быть внутри тега HTML.

Например:

Я уже создал горизонтальную линию, но не могу создать точки над ней. enter image description here

Ответы [ 2 ]

1 голос
/ 13 мая 2019

Вы можете включить что-то вроде:

<div style="margin:50px;width:450px;height:25px;overflow:hidden;">
  <div style="width:550px;height:2px;background:black;position:relative;top:5px;">
    <div style="float:left;width:10px;height:10px;background:black;border-radius:50%;position:relative;top:-4px;margin-right:100px;"></div>
    <div style="float:left;width:10px;height:10px;background:black;border-radius:50%;position:relative;top:-4px;margin-right:100px;"></div>
    <div style="float:left;width:10px;height:10px;background:black;border-radius:50%;position:relative;top:-4px;margin-right:100px;"></div>
    <div style="float:left;width:10px;height:10px;background:black;border-radius:50%;position:relative;top:-4px;margin-right:100px;"></div>
    <div style="float:left;width:10px;height:10px;background:black;border-radius:50%;position:relative;top:-4px;margin-right:100px;"></div>
  </div>
</div>

<div style="width:550px;height:2px;position:relative;left:45px;top:-55px;">
    <div style="float:left;width:10px;height:10px;position:relative;top:-4px;margin-right:100px;">text</div>
    <div style="float:left;width:10px;height:10px;position:relative;top:-4px;margin-right:100px;">some other text</div>
    <div style="float:left;width:10px;height:10px;position:relative;top:-4px;margin-right:100px;">some more text</div>
    <div style="float:left;width:10px;height:10px;position:relative;top:-4px;margin-right:100px;">guess what! text!</div>
    <div style="float:left;width:10px;height:10px;position:relative;top:-4px;margin-right:100px;">text again</div>
  </div>

Точки имеют поля справа от них, чтобы сделать интервал, и они расположены относительно, чтобы убедиться, что они находятся на линии. Была добавлена ​​оболочка, чтобы скрыть дополнительную часть справа от черной линии, которая была необходима из-за правого поля на последней точке (в противном случае точка переместилась бы на следующую строку).

Вы также можете добавить текст, используя последнюю часть HTML-кода выше.

0 голосов
/ 16 мая 2019

Вот мое решение:

.wraper {
  padding: 50px;
  text-align: center;
  font-family: sans-serif;
  width: 500px;
  margin: 10px auto;
}

h1 {
  margin: 50px auto;
}

.container {
  border-top: 2px solid #000;
  display: flex;
  list-style: none;
  padding: 0;
  justify-content: space-between;
  align-items: stretch;
  align-content: stretch;
}

.link {
  position: relative;
  margin-top: 10px;
  width: 100%;
}

.link a {
  font-weight: bold;
  text-decoration: none;
  color: black;
  text-transform: uppercase;
  font-size: 15px;
}

.link:first-child {
  margin-left: -55px;
}

.link:last-child {
  margin-right: -55px;
}

.link::after {
  content: "";
  width: 10px;
  height: 10px;
  background: #fff;
  position: absolute;
  border-radius: 10px;
  top: -18px;
  left: 50%;
  transform: translatex(-50%);
  border: 2px solid black;
}

.active::after,
.link:hover::after {
  background: black;
}

p.lead {
  font-weight: 600;
  margin: 50px auto;
  line-height: 1.5;
}
<div class="wraper">
  <h1>How We Work</h1>

  <ul class="container">
    <li class="link"><a href="">Identify</a></li>
    <li class="link"><a href="">Form</a></li>
    <li class="link active"><a href="">Develop</a></li>
    <li class="link"><a href="">Launch</a></li>
    <li class="link"><a href="">Grow</a></li>
  </ul>

  <p class="lead">A streamlined team of co-founders is brought together to create and lead the company, empowering a new generation of entrepreneurs.</p>
</div>

Надеюсь, вам это нужно:)

...