What are the steps for designing a flexbox structure?

I am looking to design a flexbox layout that includes a title, detail, and other content within one div. Additionally, I want another div with content placed closely next to the first div, all centered within the main box (referred to as container).

What have I tried so far? I created a div called container and placed the title and details inside it. However, in doing so, the close div is also contained within the container div. It should actually be outside of the container div and positioned in the center.

I aim to achieve a layout similar to the image shown below: https://i.sstatic.net/8grF6.png

Can anyone assist me in solving this issue? Here is the link to the code: https://codepen.io/anon/pen/BbaKwy

.box_wrapper {
     width: calc(100% - 450px);
     border: 1px solid green;
     margin: 0 auto;
 }
 
.container {
    display: flex;
    justify-content: space-between;
    border: 1px solid blue;
    padding: 10px;
 }
<div class="box_wrapper">
  <div class="container">
    <div class="content">
      <div>title</div>
      <div>detail</div>
    <div>
      <div>ticket number</div>
      <div>
          <h2>Debug</h2>
          someresponse
          <div/>
      </div>
   </div>
</div>
<div>close</div></div></div>
     

Thank you.

Answer №1

To achieve the desired outcome, simply rearrange the close div and include additional styles to box_wrapper

.box_wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  border: none;
  margin: 0 auto;
}

.container {
  display: flex;
  justify-content: space-between;
  width: calc(100% - 450px);
  border: 1px solid blue;
  padding: 10px;
}
<div class="box_wrapper">
  <div class="container">
    <div class="content">
      <div>title</div>
      <div>detail</div>
      <div>
        <div>ticket number</div>
        <div>
          <h2>Debug</h2>
          someresponse
          <div/>
        </div>
    </div>
    </div> 
  </div>
</div>
<div>close</div>

By adding flex-direction:row to .box_wrapper, you can position it to the right, while setting align-items:center will center it vertically.

UPDATE:

If you wish to maintain the positioning of the close div within the box_wrapper class, follow these steps:

.box_wrapper {
      display: flex;
      flex-direction: row;
      border: none;
      margin: 0 auto;
      width: calc(100% - 450px);
    }
    
    .container {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-grow: 1;
      padding: 10px;
    }
    .content {
      border: 1px solid blue;
      flex-grow: 1;
    }
<div class="box_wrapper">
      <div class="container">
        <div class="content">
          <div>title</div>
          <div>detail</div>
          <div>
            <div>ticket number</div>
            <div>
              <h2>Debug</h2>
              someresponse
              <div/>
            </div>
        </div>
        </div> 
      </div>
      <div>close</div>
    </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Center align text in the uib-progressbar

Is it possible to center align text in the uib-progressbar? I attempted using position:absolute, but I would like to display a list of progress bars in a UI grid that includes scrollable content. The goal is for the text to remain fixed while the progress ...

Is there a way to determine the negative horizontal shift of text within an HTML input element when it exceeds the horizontal boundaries?

On my website, I have a standard HTML input field for text input. To track the horizontal position of a specific word continuously, I have implemented a method using an invisible <span> element to display the content of the input field and then utili ...

Tips for displaying a page within a parent div upon clicking a button in a child div

Hey there, I'm new to scripting and I've run into a problem. I'm trying to figure out how to load a page in a parent div when clicking buttons in a child div. Specifically, I want to load a specific page in the parent div. Just to clarify, t ...

What causes Windows 7 users to consider the VS Code website unsafe?

What causes Windows 7 users to view the VS Code website as unsafe? Visit the image link here ...

Utilize Flexbox and Material UI to position Item at the bottom of the layout

I'm attempting to include Unassigned Text at the bottom of my Container, following the layout shown in this mockup:https://i.sstatic.net/863cl.png Here is the code I currently have. I'm facing difficulty in getting the border between the play bu ...

My website is currently being hosted on Github, but I am experiencing issues with the CSS. I keep getting an error message saying "Failed to load resource: the server responded

view image here I recently uploaded my website on Github and am facing an issue with the CSS file not working properly. Can someone please help me troubleshoot this problem? website link Github repository I have reviewed the links connecting the HTML t ...

Battle of Emotion and Styled-Components in CSS prop usage

In my exploration, I've noticed that utilizing the css prop in Emotion can provide support for various features. Take a look at the example below: const wrapperStyle = css` display: flex; flex-direction: column; align-items: center; `; <div ...

What causes the variation in size between the next/image and img HTML elements?

Two Images, Different Sizes! https://i.sstatic.net/vpoNG.jpg There seems to be a discrepancy in size between the image rendered by the next/img component and the one displayed using the img element. Interestingly, they both use the same image source and ar ...

Canvg | Is there a way to customize canvas elements while converting from SVG?

Recently, I encountered an issue with styling SVG graphics dynamically generated from data. The SVG graphic appears like this: https://i.sstatic.net/xvIpE.png To address the problem, I turned to Canvg in hopes of converting the SVG into an image or PDF us ...

Deciding whether to use Device WebView Kit or HTML for your project is

I am a bit confused about creating a website for mobile devices. If I have a specific webpage in mind that I want to target towards mobile devices, do I need to use the native webview kits provided by iOS, or can I simply code in HTML, PHP, Javascript, an ...

What is the best way to duplicate a CSS shape across a horizontal axis?

I am working on decorating the bottom of my page with a repeated triangle design. The image provided only displays one triangle, but I would like to extend it across the entire horizontal div. Here is a screenshot of my progress so far: https://i.stack.im ...

AngularJS : Resolving Alignment Issues with ng-repeat and ng-include

The ng-repeat feature is being utilized here with an inclusion of a different HTML partial. <div ng-repeat="item in feedItems"> <div ng-include="'item.itemType.html'"> </div> </div> Below is the CSS for the partial H ...

Why doesn't the div click event trigger when the mouse hovers over an iframe?

My dilemma involves a div element with a click event. When the div is positioned over an iframe area (closer to the user than the iframe), the click event fails to trigger. However, if the div is located elsewhere and not above the iframe, the click event ...

When I log out and hit the back button, the PHP page continues to display without any changes

After logging out of my PHP session and being redirected to the login page, I am facing an issue where pressing the back button shows me the previous page without requiring a login. How can I fix this problem? Thank you in advance. index.php <form sty ...

Using pure CSS to style sibling span elements in a unique color

Looking to change the color of a specific span based on the title attribute of another span in a different div. The code below successfully turns text2 red if it has the title of "Red". span[title=Red] ~ span { color: red; } <span title="Red" ...

Toggling in JS does not alter the DIV element

I attempted to utilize Bootstrap toggle to modify the div HTML content similar to the example shown at with a slight modification, but unfortunately, it did not function as expected due to a discrepancy in my current JavaScript code. I am unsure of what I ...

How can I increase the fading effect more and more with each call of the event using jQuery's fadeTo()?

I'm currently working on a script that is intended to gradually fade an image from 80% opacity to 1%, but every time I click, it goes straight to the set opacity. How can I make the fading effect continuous? Any help would be appreciated. Here is the ...

Automatically navigate to a different page using JavaScript after 5 seconds without interrupting the execution of other code

Is there a way to redirect to a specific URL after 5 seconds without halting the execution of other code on the page? I want all the other code to run first before triggering the redirection. Wrapping the entire page in a setTimeout block is not an option. ...

How can we modify this function to interpret multiple selections at once?

For the task of displaying multiple selections from a scrolling list to an alert, I have implemented the following function: var toppings = ""; function displaySelectedToppings() { var topList = document.getElementById('to ...

The webpage displays the element as <span class="icon">&#xe80d;</span> instead of rendering it properly

In my ReactJS project, I have created a component called Menu1item: class Menu1item extends React.Component{ render(){ return ( <div> {this.props.glyph}{this.props.value} </div> ) ...