Lortnok
Lortnok

Reputation: 59

Flexbox not aligned

I want to create 6 boxes in the middle and display some features inside.

I am using display: inline-flex but for I can't get them to align properly, the last box seems out of the place. I don't want to use Bootstrap or any other framework but make this with pure CSS.

I am expecting to have aligned 6 boxes in the middle of centered div. This is what I have tried, example of snippet

.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>

Upvotes: 0

Views: 87

Answers (2)

ramirozap
ramirozap

Reputation: 1459

Here is another solution but using CSS Grid, the html was cleaned a bit.

The key part here is this line grid-template-columns: repeat(3, 1fr); it tells to the grid that we want 3 columns and each one should use the same space 1fr (1 fraction of the available space)

.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>

Upvotes: 2

Napinator
Napinator

Reputation: 521

You shouldn't wrap everything up in so much html tags if there is no need for it, keep it clean and readable.

Also, if you add a class "jebote" for a border, just create it once and add the class "jebote" to the elements you want to apply a border. again, this will keep it clean and readable.

Although my solution is below, i highly recommend you to read this guide: 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>

Upvotes: 2

Related Questions