Flexbox не выровнен - PullRequest
       13

Flexbox не выровнен

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

Я хочу создать 6 коробок посередине и отобразить некоторые элементы внутри.

Я использую display: inline-flex, но из-за того, что я не могу их правильно выровнять, последняя коробка кажется неуместной,Я не хочу использовать Bootstrap или какой-либо другой фреймворк, но сделаю это с помощью чистого CSS.

Я ожидаю, что выровнял 6 блоков по центру центрированного div.Это то, что я пробовал, пример фрагмента

.center {
  margin: auto;
  width: 80%;
  padding: 80px;
}

.flexi {
  display: inline-flex;
}

.jebote {
  border: 3px solid green;

}
.jebote5 {
  border: 3px solid green;

}

.jebote6 {
  border: 3px solid green;

}
.h1 {
}
<div class="center">
<div class="flexi">
  <div class="inline">
    <div class="jebote">
    <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
    <p style="font-size: 20px;">Custome Software Solutions</p>
    <p style="font-size:14px;">
      Every business is unique and there is no “one-size-fits-all” when it
      comes to technology solutions that drive growth and stand you out in
      competitive market.
    </p>
    </div>
  </div>
  <div class="flexi">
    <div class="inline">
      <div class="jebote">
      <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
      <p style="font-size: 20px; ">Consulting and Strategy</p>
      <p style="font-size:14px">
        To develop efficient software and reduce the related costs, process
        and technology consulting are essential and integral part of every
        business strategy.
      </p>
      </div>
    </div>
  </div>
  <div class="flexi">
    <div class="inline">
      <div class="jebote">
      <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
      <p style="font-size: 20px;">Design and Creative Work</p>
      <p style="font-size: 14px;">
        Design plays a key role in engaging visitors and converting them
        into customers. We focus on creating memorable interactions through
        our designs.
      </p>
    </div>
  </div>
  </div>
</div>

<!--  Bottom row cards-->

<div class="flexi">
  <div class="inline">
    <div class="jebote">
    <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
    <p style="font-size: 20px;">Mobile Applications</p>
    <p style="font-size:14px;">
      We like to think of the problem the app intends to solve, analyze
      mobility context and create a mobile solution meeting that need and
      satisfying user experience.
    </p>
  </div>
  </div>


  <div class="flexi">
    <div class="inline">
      <div class="jebote5">
      <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
      <p style="font-size: 20px;">Website Development</p>
      <p style="font-size:14px">
        Professional, responsive, engaging and value driven web sites are
        true support to every business. They help engage the customers and
        gain an edge over the competitors.
      </p>
    </div>
  </div>
  </div>


  <div class="flexi">
    <div class="inline">
      <div class="jebote6">
      <a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/></a>
      <p style="font-size: 20px;">E-Commerce Development</p>
      <p style="font-size: 14px;">
        Building intuitive, useful, secure and accessible e-Commerce
        solutions that power the transactions and digital experience is
        important to us..
      </p>
    </div>
    </div>
  </div>
</div>
  </div>

Ответы [ 2 ]

2 голосов
/ 15 мая 2019

Вот еще одно решение, но с использованием CSS Grid html был немного очищен.

Ключевая часть здесь - это строка grid-template-columns: repeat(3, 1fr);, которая сообщает сетке, что нам нужно 3 столбца, и каждый из них должен использоватьто же пространство 1fr (1 доля доступного пространства)

.center {
  margin: auto;
  width: 80%;
  padding: 80px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.flexi {
  border: 3px solid green;
}
	<div class="center">

		<div class="flexi">
			<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
			<p style="font-size: 20px;">Custome Software Solutions</p>
			<p style="font-size:14px;">
				Every business is unique and there is no “one-size-fits-all” when it
				comes to technology solutions that drive growth and stand you out in
				competitive market.
			</p>
		</div>
		<div class="flexi">
			<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
			<p style="font-size: 20px; ">Consulting and Strategy</p>
			<p style="font-size:14px">
				To develop efficient software and reduce the related costs, process
				and technology consulting are essential and integral part of every
				business strategy.
			</p>
		</div>
		<div class="flexi">
			<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
			<p style="font-size: 20px;">Design and Creative Work</p>
			<p style="font-size: 14px;">
				Design plays a key role in engaging visitors and converting them
				into customers. We focus on creating memorable interactions through
				our designs.
			</p>
		</div>

		<!--  Bottom row cards-->

		<div class="flexi">
			<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
			<p style="font-size: 20px;">Mobile Applications</p>
			<p style="font-size:14px;">
				We like to think of the problem the app intends to solve, analyze
				mobility context and create a mobile solution meeting that need and
				satisfying user experience.
			</p>
		</div>


			<div class="flexi">
				<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
				<p style="font-size: 20px;">Website Development</p>
				<p style="font-size:14px">
					Professional, responsive, engaging and value driven web sites are
					true support to every business. They help engage the customers and
					gain an edge over the competitors.
				</p>
			</div>

			<div class="flexi">
				<a href="#news"><img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png" /></a>
				<p style="font-size: 20px;">E-Commerce Development</p>
				<p style="font-size: 14px;">
					Building intuitive, useful, secure and accessible e-Commerce
					solutions that power the transactions and digital experience is
					important to us..
				</p>
			</div>
		</div>
2 голосов
/ 15 мая 2019

Вы не должны оборачивать все в так много HTML-тегов, если в этом нет необходимости, сохраняйте их чистыми и удобочитаемыми.

Кроме того, если вы добавляете класс "jebote" для границы, простосоздайте его один раз и добавьте класс «jebote» к элементам, к которым вы хотите применить границу.Опять же, это будет держать его в чистоте и удобочитаемости.

Хотя мое решение ниже, я настоятельно рекомендую вам прочитать это руководство: https://css -tricks.com / snippets / css / a-guide-to-flexbox /

<style>
  .center {
    margin: auto;
    width: 80%;
    padding: 80px;
  }

  .flex-row {
    display: flex;
  }

  .jebote {
    border: 2px solid green;
  }
</style>
<div class="center">
  <div class="flex-row">
    <div class="jebote">
      <a href="#news">
        <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
      </a>
      <p style="font-size: 20px;">Custome Software Solutions</p>
      <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
    </div>
    <div class="jebote">
      <a href="#news">
        <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
      </a>
      <p style="font-size: 20px;">Custome Software Solutions</p>
      <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
    </div>
    <div class="jebote">
      <a href="#news">
        <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
      </a>
      <p style="font-size: 20px;">Custome Software Solutions</p>
      <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
    </div>
  </div>
  <div class="flex-row">
    <div class="jebote">
      <a href="#news">
        <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
      </a>
      <p style="font-size: 20px;">Custome Software Solutions</p>
      <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
    </div>  <div class="jebote">
    <a href="#news">
      <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
    </a>
    <p style="font-size: 20px;">Custome Software Solutions</p>
    <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
  </div>
    <div class="jebote">
      <a href="#news">
        <img src="http://files.softicons.com/download/toolbar-icons/free-green-button-icons-by-aha-soft/png/40x40/theater%20symbol.png"/>
      </a>
      <p style="font-size: 20px;">Custome Software Solutions</p>
      <p style="font-size:14px;">Every business is unique and there is no “one-size-fits-all” when itcomes to technology solutions that drive growth and stand you out incompetitive market.</p>
    </div>
  </div>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...