float right element outside of parent

River CR Phoenix

I have a parent div and three children. i want one to float left of parent, one to be in exact center of parent and one to float right of parent. but the floated right element has gone outside of the parent div. its not because of lack of space.

fiddle

#boards {
  width: 100%;
  height: 500px;
  background-color: white;
  text-align: center;
}
#boards p {
  font-family: 'bebas_neueregular';
  color: rgba(160, 224, 247, 1);
  margin-top: 30px;
  font-size: 50px;
}
.board_items {
  width: 250px;
  height: 300px;
  background-color: gray;
}
#board_items_container {
  width: 85%;
  margin-left: auto;
  margin-right: auto;
  height: auto;
  background-color: orange;
  padding: relative;
}
#board1 {
  float: left;
  padding: relative;
}
#board2 {
  margin-left: auto;
  margin-right: auto;
  padding: relative;
}
#board3 {
  float: right;
  padding: relative;
}
<div id="boards">
  <p>TOP BOARDS</p>
  <div id="board_items_container">
    <div id="board1" class="board_items">
    </div>
    <div id="board2" class="board_items">
    </div>
    <div id="board3" class="board_items">
    </div>
  </div>
</div>

Blazemonger

In your HTML, move the right-floated element before the element you want it to float around:

<div id="boards">
  <p>TOP BOARDS</p>
  <div id="board_items_container">
    <div id="board1" class="board_items"> <!-- float: left -->
    </div>
    <div id="board3" class="board_items"> <!-- float: right -->
    </div>
    <div id="board2" class="board_items"> <!-- not floated -->
    </div>
  </div>
</div>

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Overflowing a child element outside the parent element

分類Dev

Child elements expanding outside parent element with flex

分類Dev

Make element float right, but overflow and scroll if there isn't enough width

分類Dev

Position div outside of parent

分類Dev

Children not clickable outside parent view

分類Dev

Changing the right element

分類Dev

Right alignment without resizing parent

分類Dev

Calling the right overloaded parent method

分類Dev

Select parent element in stylus

分類Dev

div container floats outside of parent container

分類Dev

absolute div visibility outside of div relative parent

分類Dev

Child divs going outside of parent divs

分類Dev

pull/float right not working in Bootstrap 4

分類Dev

Sticky Bar Can't do the float:right

分類Dev

Float column to the right using only necessary height

分類Dev

HTML float right drop to next line

分類Dev

How to fix an element to the right of div?

分類Dev

Align right content in div element

分類Dev

Mouseover/Mouseenter event outside of bounds of element

分類Dev

Selector for the child element for the current parent element

分類Dev

React is not changing the state of the parent element

分類Dev

XPath find parent of a child element

分類Dev

nested element firing parent event

分類Dev

put element on bottom of parent container

分類Dev

Element not filling parent in angular material

分類Dev

jquery find element considering parent

分類Dev

Tooltip hidden inside parent element

分類Dev

Javascript external file does not find the right element

分類Dev

Element overflow direction right to left problems

Related 関連記事

ホットタグ

アーカイブ