Tips for creating line breaks between two anchor elements

I've been attempting to format my two anchor tags enclosed in a flip box with line breaks. Currently, both anchors are inline which is causing an issue due to the flexbox styling applied to the container. I'm struggling to figure out how to move the second anchor below the first one.

Here's my HTML code: Codepen Link

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

<div style="display: flex; align-items: center;  justify-content: center;" class="flip-box-back">
  <i class="fas fa-download"></i>
  <a href="#" download>download</a>
  <hr>
  <div class="break">
    <i class="fas fa-eye"></i>
    <a href="#">view</a>
  </div>
</div>

I have already tried using the <br> and <hr> elements in the HTML code without success.

For reference:
https://i.sstatic.net/znJjB.png

Your help will be greatly appreciated. Thank you in advance.

Answer №1

To achieve a column layout for your buttons, make sure you include the CSS rule flex-flow: column; in the wrapping div

div {
 display: flex;
 flex-flow: column;
 }
<div>
<button>1</button>
<button>2</button>
</div>

Answer №2

If you want to ensure that your links and icons are positioned correctly, you should wrap each link and icon inside a container element like a div. This way, the icon and link won't stack on top of each other but will be placed next to each other as two separate "buttons".

To achieve this layout, you can use CSS properties like flex-direction: column; to position each wrapped element accordingly.

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

<div style="display: flex; flex-direction: column;  align-items: center;  justify-content: center;" class="flip-box-back">
  <div>
    <i class="fas fa-download"></i>
    <a href="#" download>download</a>
  </div>
  <div class="break">
    <i class="fas fa-eye"></i>
    <a href="#">view</a>
  </div>
</div>

Answer №3

To ensure flexibility in a flexbox layout, the default setting is typically no-wrap. However, you can allow elements to break onto a new line when there is limited space by adding properties such as flex-wrap: wrap and adjusting horizontal alignment with justify-content:

.flexbox{
 display: flex;
}
.flexbox2{
 display: flex;
 flex-wrap: wrap;
 justify-content: center;
}
.flexbox3{
 display: flex;
 flex-direction: column;
 align-items: center;
}

button{
  width: 60vw;
}
Default:
<div class="flexbox">
 <button>Button1</button>
 <button>Button2</button>
</div>


With (auto) wrap:

<div class="flexbox2">
 <button>Button1</button>
 <button>Button2</button>
</div>

With forced wrap (column view):

<div class="flexbox3">
 <button>Button1</button>
 <button>Button2</button>
</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

Ways to identify when a person has scrolled a specific distance

Is it possible to modify the appearance of my top navigation bar once the page has been scrolled a specific number of pixels? I assume this requires some sort of listener to track the amount of scrolling. I came across element.scrollTop, but it doesn' ...

"Emulate the social sharing capabilities of CNET with interactive share

I remember a while ago, CNET had these amazing Social Share buttons that, when clicked, would reveal a "dropdown box" with the social network share dialog. Does anyone know how they achieved that? I've searched but couldn't find any information ...

Arrangement of a pair of elements within a single sequence

Can someone help me align the text and icons (login, shop) to be at the same level as the 'Logo,' but on the right side? I attempted to adjust the '.shop-icon' with {margin: -30px auto;}, but it ended up messing up the entire page layou ...

How to center a position:absolute div inside a position:relative parent div

Regarding: http://jsfiddle.net/WdGdd/3/ I am wondering if it is achievable to center a div with position:absolute within its parent div with position:relative? The goal is to create a button that displays one of two possible values. The width of the butt ...

Guide for Sending a Textnode from One Page to a Different Page within a Specific Id Element through PHP

firstpage.html : <body> <?php $text = $_POST['text']; ?> <p style = "color:red; " id = "getext"><?php echo $text; ?></p> </body> secondpage.php : <body> <?php $text = $_POST['text']; ?> ...

Determine the differences in the content of the body section of an HTML file using

I am in the process of creating a shell script that can track changes on a website and send me an email with the content of the change if any. To achieve this, I am using wget to download a copy of the HTML and then comparing it to the version saved from t ...

I'm currently in the process of creating a Firefox extension and my goal is to accurately count the total number of text boxes on a webpage while excluding any hidden text boxes. Can someone please

As I work on creating a Firefox extension, I am faced with the task of counting the total number of visible text boxes on a webpage while ignoring any hidden ones. Many webpages contain hidden text fields for future use, so my goal is to exclude these fr ...

Adjust the brightness of a specified oklch color by 50% using CSS oklch(from ...) in combination with the calc() function

We have implemented a design system that includes various CSS custom properties for colors. For example: :root { --color--blue-1: oklch(88.6% 0.023 238); } Our latest addition is the utilization of the oklch color format. Currently, I am tasked with ca ...

Is the transition not smooth when sliding the element up and down on mobile devices?

I have successfully implemented a modal that slides up and down when clicked using CSS and jQuery. While it looks decent on desktop, the animation is choppy on mobile devices, especially when the modal slides down. I have searched for solutions to achiev ...

Enhance the dropdown menu by incorporating a caret icon

Click here for the image, I am trying to incorporate the Bootstrap caret class into my select dropdown menu. .select_menu{ font-size: 12px; outline: none; border: thin #ddd solid; -webkit-appearance: none; -moz-appearance: none; appearance: ...

When scrolling, the header will automatically disappear until you reach the bottom. Once you start scrolling back up, the header

I couldn't quite figure out how to phrase this question, so I'm not sure if it's been asked before.. There is a header that disappears as you scroll down, like this: let prevScrollpos = window.pageYOffset; window.onscroll = function() { ...

Links are functional in browsers, but seem to be unresponsive on iPad devices

I'm currently developing a website that allows users to navigate using swipe gestures. Each slide contains multiple links that should redirect users to different locations upon clicking. However, I've encountered a bizarre issue where the links a ...

Google Maps problem: cross-origin framing is not allowed

I've encountered an issue with the custom Google Maps embedded using iframe. The error message I'm getting is: does not permit cross-origin framing. Instead of displaying a blank iframe, I would like to change it to show a "map cannot be disp ...

Positioning a relative element after a fixed element: Tips and tricks

I can't seem to figure out how to make a position:relative element display after a position:fixed element. In my code snippet, there is a green section representing the relative element and a blue fixed element. By using padding-top, I am able to posi ...

Invoke a C# method within an ASP.NET environment by clicking on an HTML hyperlink

I have a page called myEditPage.aspx that contains both inputs and TextAreas. I want to upload the data from these elements to a database, but to accomplish this, I need to create a link using <a href=".."> that will connect to a function in my myEdi ...

What steps should I take to resolve the issue of missing files on my local website?

While working on my pokedex project using HTML, CSS, and JavaScript, I encountered an issue. When I try to open the project in VSCODE, everything works perfectly fine. However, when attempting to open the HTML file locally in a browser, it fails to find tw ...

CSS - Safari has trouble properly implementing clip-path

I'm currently working on a shape-based menu, but I'm encountering issues specifically in Safari. The layout gets distorted in Safari, and I'm struggling to understand the cause. Interestingly, when I use CSS clip-path without the SVG tag, it ...

New to CSS: Applying a background image on top of a gradient without any transparency on the image

Appreciate you taking the time to read this I'm facing an issue where I want to have a background image overlaid on a gradient, but every solution I've tried ends up making the background image transparent, causing a discrepancy in colors. I att ...

The submit button is not lining up properly with the input field

I've encountered an issue while creating a search bar with a submit button. When I link the input box to a class in my CSS document, it causes misalignment between the box and the button. Here's a visual representation of the problem: Current Al ...

The scrolltop function is dysfunctional on CentOS operating systems

I'm currently working on implementing smooth scrolling functionality when a button is clicked. The feature works perfectly fine with a local Apache server and IE10+, but when the project is deployed on "CentOS", it doesn't work on the same browse ...