Display the icon beneath the list item label

How can I display the ion-edit icon below the list names? The icons are currently appearing on the right side of each list name, but I want them to be aligned below with some spacing.

When clicking on "Data Source Connections," a sublist will be shown where the pencil icon needs to be aligned below each name.

Is there a CSS property that needs to be included?

$('.src-sub-menu').click(function() {
  $(this).toggleClass('submenu-open').parent('li').siblings('li').children('h4.submenu-open').removeClass('submenu-open');
  $(this).parent().toggleClass('submenu-opensubmenu-open').children('ul').slideToggle(500).end().siblings('.submenu-open').removeClass('submenu-open').children('ul').slideUp(500);
  $('html, body').animate({
    scrollTop: (0),
  }, "fast"); /*this will scroll up to the top, not sure if I want to use this yet */
});
.whole-dbsource {
  height: 100%;
}

.db-pagerow {
  margin-left: 12%;
  justify-content: center;
  height: 80%;
}

.source-container {
  height: 300px; /* ED: Changed to see the dropdown */
  border-radius: 10px;
  background-color: white;
  overflow: scroll;
  position: relative;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.26);
}

h5 {
  padding: 10px;
  margin: 0;
}

h5.submenu-open {
  padding: 10px;
  color: white;
  background-color: #28be9a;
}

ul.src-main-menu {
  position: relative;
  list-style-type: none;
  height: 12px;
}

ul.src-main-menu .src-main-sub {
  margin: 20px 0;
}

ul.src-main-menu li.src-main-sub {
  padding: 1px 0px;
  cursor: pointer;
  background-color: #e0e0e0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

ul.src-main-menu li ul {
  list-style-type: none;
  color: black;
  display: none;
  position: relative;
  max-height: 1000px;
  /*fallback for FireFox */
  height: 100%;
}

ul.src-main-menu li ul i {
  display: inline-block;
}

.src-main-sub ul li {
  border-bottom: 1px solid black;
  margin: 20px 0;
}

.src-main-sub ul li:last-child {
  border-bottom: none;
  margin: 0;
}

ul.src-main-menu li ul.open {
  display: block;
}

ul.src-main-menu .src-main-sub i {
  transition: all 0.5s;
  position: absolute;
  right: 10px;
}

ul.src-main-menu li i.closed {
  transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
}

ul.src-main-menu li i.open {
  transform: rotate(360deg);
  -webkit-transform: rotate(360deg);
  -moz-transform: rotate(360deg);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"/>

<div class="container-fluid whole-dbsource">
  <div class="row db-pagerow">
    <div class="col-sm-7 source-container">
      <ul class="src-main-menu">
        <li class="src-main-sub">
          <h5 class="src-sub-menu">Data Source Connections<i class="ion-chevron-down closed"></i></h5>
          <ul class="closed">
            <li>Oracle 12c<i class="ion-edit"></i></li>
            <li>PostgresSQL<i class="ion-edit"></i></li>
            <li>MySql<i class="ion-edit"></i></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</div>

Answer №1

$('.src-sub-menu').click(function() {
  $(this).toggleClass('submenu-open').parent('li').siblings('li').children('h4.submenu-open').removeClass('submenu-open');
  $(this).parent().toggleClass('submenu-opensubmenu-open').children('ul').slideToggle(500).end().siblings('.submenu-open').removeClass('submenu-open').children('ul').slideUp(500);
  $('html, body').animate({
    scrollTop: (0),
  }, "fast"); /*this will scroll upto the top, not sure if I want to use this yet */
});
.whole-dbsource {
  height: 100%;
}

.db-pagerow {
  margin-left: 12%;
  justify-content: center;
  height: 80%;
}

.source-container {
  height: 300px; /* ED: Changed to see the dropdown */
  border-radius: 10px;
  background-color: white;
  overflow: scroll;
  position: relative;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.26);
}

h5 {
  padding: 10px;
  margin: 0;
}

h5.submenu-open {
  padding: 10px;
  color: white;
  background-color: #28be9a;
}

ul.src-main-menu {
  position: relative;
  list-style-type: none;
  height: 12px;
}

ul.src-main-menu .src-main-sub {
  margin: 20px 0;
}

ul.src-main-menu li.src-main-sub {
  padding: 1px 0px;
  cursor: pointer;
  background-color: #e0e0e0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

ul.src-main-menu li ul {
  list-style-type: none;
  color: black;
  display: none;
  position: relative;
  max-height: 1000px;
  /*fallback for FireFox */
  height: 100%;
  margin:0;
  padding:0;
}

ul.src-main-menu li ul i {
  display: inline-block;
}

.src-main-sub ul li {
  border-bottom: 1px solid black;
  margin: 20px 0;
  padding:0 5px;
}

.src-main-sub ul li:last-child {
  border-bottom: none;
  margin: 0;
}

ul.src-main-menu li ul.open {
  display: block;
}

ul.src-main-menu .src-main-sub i {
  transition: all 0.5s;
   
}
ul.src-main-menu .src-main-sub i.ion-chevron-down {
  transition: all 0.5s;
  position: static;
  left: 0;
}

ul.src-main-menu li i.closed {
  transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
}

ul.src-main-menu li i.open {
  transform: rotate(360deg);
  -webkit-transform: rotate(360deg);
  -moz-transform: rotate(360deg);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"/>

<div class="container-fluid whole-dbsource">
  <div class="row db-pagerow">
    <div class="col-sm-7 source-container">
      <ul class="src-main-menu">
        <li class="src-main-sub">
          <h5 class="src-sub-menu">Data Source Connections<i class="ion-chevron-down closed float-right"></i></h5>
          <ul class="closed">
            <li><span class='d-block'>Oracle 12c</span><i class="ion-edit d-block mt-2"></i></li>
            <li><span class='d-block'>PostgresSQL</span><i class="ion-edit d-block mt-2"></i></li>
            <li><span class='d-block'>MySql</span><i class="ion-edit d-block mt-2"></i></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</div>

Answer №2

The section of code responsible for aligning your icons to the right can be removed to observe the resulting effect.

ul.src-main-menu .src-main-sub i {
  transition: all 0.5s;
  position: absolute;
  right: 10px;
}

To achieve your desired outcome, use the following code:

.closed li{
    display: flex;
    justify-content: center; // you may remove this line if center alignment is not required
    align-items: center;
    flex-direction: column;
}

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

Personalized AWS Cognito: Strategies for Tailoring Input Field Designs

MY CURRENT CHALLENGE: Within my Vue application, I am utilizing the AWS authenticator for managing login and signup processes. However, customizing its style has proven to be difficult due to the structure being built with shadow DOM elements. https://i. ...

What could be causing my jQuery script to not load properly on the first attempt?

I have a jQuery script set up on this particular webpage just before the ending body tag. Here is the script: <script> $(document).ready(function(){ var demomain = $(".demo-bg section"); var demomainW = demomain.height()+ 150 ...

Symbol '%' is not supported in Internet Explorer

My experience with IE versions 8 and 9 has been that they do not recognize the &percnt; entity. I have tested this on two different computers. I found information suggesting that it should be supported in IE here: http://code.google.com/p/doctype/wiki ...

Stringified HTML code showcased

When working with Angular, I have encountered an issue where I am calling a function inside an .html file that returns a string containing a table element. My goal is to convert this string into HTML code. I attempted to use [innerHtml]: <p [innerHtml ...

Incorporating a complex React (Typescript) component into an HTML page: A Step-by

I used to have an old website that was originally built with Vanilia Javascript. Now, I am in the process of converting it to React and encountering some issues. I am trying to render a compound React(Typescript) component on an HTML page, but unfortunatel ...

What are the steps to sending HTML emails from the default mail client on Mac and PC operating systems?

Currently, I am in the process of creating a website that allows clients to easily send an email with the content they are viewing. I want users to click on a button which will open their default mail client (compatible with both Mac and PC) and automatica ...

Disabled radio buttons are appearing as if they have been chosen

While working on customizing the styles of radio buttons in a form, I encountered an issue where disabled radio buttons appeared selected even though they were supposed to show as disabled. Here is the code snippet that I used: input ::-ms-clear { ...

Display a block by using the focus() method

My objective is : To display a popin when the user clicks on a button To hide the popin when the user clicks elsewhere I previously implemented this solution successfully: Use jQuery to hide a DIV when the user clicks outside of it However, I wanted to ...

Using jQuery, wrap two specific HTML elements together

I am working with a set of elements: <div id="one">ONE</div> <div id="two">TWO</div> <div id="three">THREE</div> <div id="four">FOUR</div> <div id="five">FIVE</div> My goal is to wrap a DIV tag ...

Is there a way for me to send a form containing pre-existing data from a different page?

Seeking advice: I realize that utilizing jQuery's ajax function may be the simplest approach, however I am facing an issue with the form field names. The var_dump below displays the typical values submitted by the form using test data. It appears that ...

What is the best method to display an asterisk (*) in red while using React and Material UI

In my form, I want to indicate required fields with a red star (*). Is there a way to display the star in red color? Also, why does the border turn blue when I click on an input field? Here is the code and screenshot for reference: https://codesandbox.io/ ...

Is it possible to achieve a seamless change using show/hide jQuery functions when hovering over an

How can I achieve smooth transitions when using an image map to show a div on hover, similar to the functionality seen on this website: ? Below is my current JavaScript code: var mapObject = { hover : function(area, event) { var id = area.attr ...

Utilizing a jQuery variable within an .html() method

Can a Jquery if statement be used to display different content inside a div based on a variable? For example, if the variable is set to "cats", the displayed content might say "I like cats", and if it changes to "dogs", it would read "I like dogs". Is this ...

jQuery: Issue Encountered with POST Request when Offline (iOS & Chrome)

After developing an HTML5 web application with offline capabilities using AppCache, the process flow is as follows: Online: While connected to the network, the app loads base information in advance. Offline: Users can take the app offline on their tablet ...

Just starting to learn jquery and I'm struggling with this code, can someone help?

I am trying to move the .icon element to the right and animate it based on its position().left value. Unfortunately, my code is not working as expected and I can't figure out why. It seems like such a simple task! <script> $("li.menu-item").ho ...

JavaScript Issue Causing Jquery Carousel Dysfunction

I am having trouble with the slider I created using JS Fiddle. The link to the slider is not working and I need some assistance. Click here for the slider <div class="row"> <div id="myCarousel" class="carousel slide vertical"> &l ...

Tips for responding to and disabling a specific button in Vuetify.js after clicking the follow or unfollow button

I have a situation where I need to implement a functionality for a series of buttons with follow and unfollow statuses. When a user clicks on any button, I want the status to change after a brief delay and deactivation, followed by reactivation. For instan ...

Unable to align a 1px element with the primary border

Can you please assist me? I would like to modify the CSS markup below in order to remove the 1 pixel added extra on the active clicked tab from my UL LI Tabbed Menu. How can this be achieved? Here is a picture of the issue: HTML Markup: <div class=" ...

The content contained within the .each loop within the click event is only executed a single time

While working on coding a menu opening animation, I encountered an issue today. Upon clicking the menu button, the menu opens and the elements inside receive an added class (resulting in a fade-in effect). Clicking the menu button again should close the ...

Leveraging backstretch.js in combination with blur.js (or equivalent)

Query Update I provided a response to the query below, however, I am experiencing some lag and a noticeable stepped transition between images. Can anyone offer advice on how to optimize this issue? Perhaps it would be better to go back to using a static ...