Aligning the up and down vote buttons in Bootstrap for small screens

I'm currently working on implementing a voting system similar to that of Stack Overflow. However, I'm facing an issue with displaying the arrows on smaller screens. I want the arrows to be positioned next to the text, just like on StackOverflow.

On smaller screens, the arrows appear on two separate lines, which you can see in this screenshot

Here's what I have tried so far:

<div class="row">

  <div class="col-md-2" style="font-size: 1em; color: #606060;">
     <span class="fa fa-caret-up"></span>
     <span>12</span>
     <span class="fa fa-caret-down"></span>
   </div>                                                             
   <div class="col-md-10">
          <h3>Column</h3>    
           <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>        
           <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p> 
    </div>
</div>

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-xs-1" style="font-size: 30px; color:#606060; text-align: center;">
        <span class="fa fa-caret-up col-md-12"></span>
        <span class="col-md-12">12</span>
        <!-- Number goes here -->
        <span class="fa fa-caret-down col-md-12"></span>
      </div>
      <div class="col-xs-11">
        <h3>Column</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
      </div>
    </div>
  </div>

</body>

</html>

Answer №1

I apologize for not grasping the issue right away. Nevertheless, this solution should assist you:

<div class="row"  style="display:table;">
      <span class="fa fa-caret-up col-md-12" style=""></span>
      <span class="col-md-12" style="">12</span>
      <!-- Number goes here -->
      <span class="fa fa-caret-down col-md-12" style=""></span>
      <div class="col-xs-11"  style="table-cell">
        <h3>Column</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
        <h3>Column</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
        <h3>Column</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
      </div>

https://jsfiddle.net/cpkgxd1y/1/

Answer №2

Do you anticipate something like this:

body{
margin:0;
padding:0;
}
.row{
margin:0 !important;
}
.voting{
width:120px;
font-size: 2em;
color: #606060;
display:flex;
flex-direction:column; 
text-align:center;
}
<script src="https://use.fontawesome.com/ecdc7512a9.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="row">
  <div class="voting">
     <span class="fa fa-caret-up"></span>
     <span>12</span>
     <span class="fa fa-caret-down"></span>
   </div>                                                             
   <div class="col-xl-8" style="width:calc(100% - 120px);">
          <h3>Column</h3>    
           <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>        
           <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p> 
    </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

Troubleshooting: Issues with CSS fixed positioning

Whenever I try to scroll down, my navbar moves along with the page. Even when I resize the window, it keeps shifting despite using position:fixed. What mistake am I making? nav li:nth-child(1) { position: fixed; border: 1px solid #15317E; font-si ...

"Enhancing User Experience by Enabling Full Clickability on List Items

I am working on a hamburger menu with a dropdown feature, and I want the entire dropdown menu to be clickable instead of just the text. Below is my current code which only allows clicking on the text. cshtml <nav class="navbar fixed-top navbar-dark bg ...

equal child width as parent column container

I'm in the process of developing a custom dropdown search bar that presents results as the user enters text. One issue I'm facing is that the list of results must have a position: absolute. This causes it to disregard the width of the parent col ...

Problem with items overlapping in hoverable drop-down menu

I have been attempting to create a hoverable dropdown menu, but I am encountering an issue where the items of the dropdown are overlapping. Despite my efforts to adjust the CSS classes, I have not been successful in fixing this problem. Additionally, I ha ...

Steps for adjusting the position of this div in relation to the main container

Apologies in advance for my lack of HTML skills. I am struggling with a page layout issue. I have a website at . When the window is resized, the ads div on the right side overlaps the main container. What I would like to achieve is to make this ads div re ...

Adjusting the size of a button in HTML and CSS

Check out this code: /* custom button */ *, *:after, *:before { box-sizing: border-box; } .checkbox { position: relative; display: inline-block; } .checkbox:after, .checkbox:before { font-family: FontAwesome; font-feature-settings: normal; - ...

Footer not adhering to the bottom of specific pages

I have been using the code snippet below to ensure that most of my pages stick to the bottom. However, I've noticed that the ones that don't are sub-menu items that contain a contact form with captcha. I'm not sure what's causing this i ...

Inline display with automatic margin

I am seeking guidance from someone with more experience to help identify the source of this margin. Your assistance is greatly appreciated! https://i.stack.imgur.com/46k7k.png Below is the CSS code in question: .logo-icon { background-image: url(&ap ...

Why is the video background not taking up the entire width of the div element?

I've recently integrated the jquery.videoBG plugin into my project to add a video background. Here's the HTML code: <div id="div_demo"> <div class="videoBG"> <video autoplay="" src="media/snow.mp4" style="position: abso ...

Having difficulty incorporating external SASS styles into my React.js project

In most of my projects, I follow a similar process for importing SASS styles. First, I create my react app and then install SASS using the command npm install node-sass. Next, I import my SASS file into my app components as shown below: import React from & ...

Adjust the transparency of a distant div element by using CSS checkboxes without any JavaScript

I'm faced with the challenge of manipulating the opacity or animating an array of items that are all contained within a single div. In addition to altering the opacity of each individual item, I also want to change the opacity of the entire div and it ...

A step-by-step guide on incorporating RAW css into your Jekyll website

I am experiencing an issue with loading a CSS file on my website. <link rel="stylesheet" href="/assets/css/my_file.css"> This file is located at _assets/css/my_file.css. However, when I try to load the page, the CSS file does no ...

Unlocking the Potential of Larger jQuery Icons

In a recent announcement, the jQuery team unveiled new icons for their UI components. However, I have been unable to locate any examples of how to use them or where they can be downloaded from. Also, it appears that the themes in the ThemeRoller only provi ...

Behavior of Bootstrap Modal When Closing

I'm encountering an issue with a button labeled Sign Up that is supposed to load content in the form of a Modal from another file. Initially, when I click the button for the first time, everything works smoothly without any errors or warnings. However ...

What is the best way to extract and analyze CSS code from an HTML page using Java programming language

I'm looking to extract and parse the content of HTML pages using the Jsoup API, which can be found at . However, I've encountered a challenge in extracting CSS that is located in a different folder. How can this be achieved? Currently, my code ...

Challenges encountered while making CSS adjustments on the Wordpress Twentyfourteen theme

I'm currently assisting a friend with making some final adjustments to their website. The site is built on Wordpress using the Twentyfourteen theme and can be found at centromariposa.no. Most of the modifications have been completed, but I'm fac ...

The erratic appearance of inactive elements within ExtJS components

I am currently working on an ExtJS form that utilizes hbox-layout containers to generate sentences containing various form inputs. There is a specific requirement to disable the form under certain conditions. These hbox-layout containers consist of compone ...

Having trouble implementing a CSS style for a Kendo-checkbox within a Kendo-treeview component

I am facing a The issue I am encountering is that while the CSS for k-treeview is being applied from the scss file, it is not being applied for the kendo-checkbox I attempted to resolve the problem by using the following code: <kendo-treeview ...

The hyperlink for social media is not functioning properly within a list element

Having some trouble with the href-tags for social media on my contact page. Clicking on them doesn't seem to do anything. Any ideas on what might be causing this issue? html { height: 100%; box-sizing: border-box; background-color: #001725; ...

Create a basic grid layout using Bootstrap

I'm struggling to create this straightforward grid layout using Bootstrap: https://i.sstatic.net/fnQRt.png Essentially, I attempted the following method based on Bootstrap documentation: <td> <div class="row"> <div class=&q ...