problem with navigation and right float orientation

I am trying to showcase two div elements inside a navigation bar on the right side of the screen. The issue I'm facing is that when I apply float: right to this particular div

<div _ngcontent-c9="" class=" ng-clock docs-homepage-row menuSup">
in the CSS, it doesn't align properly on the right-hand side.

   <nav _ngcontent-c1="" class=" ng-clock docs-navbar-header menuDate">
     <div _ngcontent-c9="" class=" ng-clock docs-homepage-row menuSup">


       <div _ngcontent-c9="" class=" ng-clock docs-homepage-promo-img">
         ...
      </div>

      <div _ngcontent-c9="" class=" ng-clock docs-homepage-promo-img" >
         ...
      </div>

    </div>
  </nav>

CSS

.docs-navbar-header[_ngcontent-c1] {
display : flex;
flex-wrap : wrap;
align-items : center;
padding : 12px 16px;
}

.menuDate{
  width: 100%;
  background: var(--defaultColorDark);
}

.docs-homepage-row[_ngcontent-c9] {
display : flex;
max-width : 920px;
margin : 60px 0;
float: right;
}

.menuSup[_ngcontent-c9] {
display : flex;
width: 100%;
margin : 10px 10px;
float: right;
}

.docs-homepage-row[_ngcontent-c9] .docs-svg-image[_ngcontent-c9] {
max-width : 90%;
}

.docs-homepage-promo-desc[_ngcontent-c9], .docs-homepage-promo-img[_ngcontent-c9] {
width : 50%;
}
.docs-homepage-promo-img[_ngcontent-c9] {
text-align : center;
margin-top: 20px;

}

Answer №1

There are numerous ways to accomplish your goal, but utilizing the float property may not always be the most effective choice. The best option will depend on the specific context.

[SUGGESTION #1] (recommended)

If .docs-homepage-row.menuSup is the sole child of .docs-navbar-header.menuDate, you can easily use justify-content: flex-end; on .docs-navbar-header.menuDate.

To learn more about Flexbox, visit: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

[SUGGESTION #2] (useful)

By applying margin-left: auto; to .docs-homepage-row.menuSup, you can shift the flex-item to the right.

[SUGGESTION #3] (not recommended)

If you must utilize float for some reason, keep in mind that you will need to "clear" the following element. The recommended approach is using the clearfix hack on the parent element.

For more information on the clearfix hack, check out this link: https://css-tricks.com/snippets/css/clear-fix/

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

Creating a dropdown menu in Semantic UI React that includes icons with images

I'm looking for help with using a local jpg image instead of an icon on a Dropdown object in Semantic UI React. Can anyone provide guidance on how to achieve this? You can view the dropdown I'm currently using and how it functions without an ico ...

AngularJS routing: Routing without considering query parameters

I thought this would be an easy fix, but I can't seem to find the right answer anywhere. // Here is a snippet of my routing file ... .when('/pathA', templateA) .when('/pathB', templateB) .otherwise({ redirectTo: &a ...

Error message in three.min.js version 2: The Object3D cannot be added because it is not an instance of THREE.Object3

Encountering an issue with the error message "three.min.js:2 THREE.Object3D.add: object not an instance of THREE.Object3D" when attempting to run a 3D object. const loader = new THREE.OBJLoader(); loader.load("./model/Room.obj", function (obje ...

Struggling to display transparent webm files in three.js?

When working with Three.js, you have the ability to incorporate transparent materials and utilize webm videos that support transparency. However, I am encountering two unsatisfactory outcomes when attempting to insert a transparent webm video into a materi ...

Using Javascript to update text within HTML elements without affecting the structure for upcoming event listeners

I've been working on a piece of code that identifies a specific string of characters (_aff.tractionsCode) and swaps it out with another string (tractionsId). The implementation looks something like this: content = document.body.innerHTML.replace(_aff ...

Is there a way for me to access the current templating in AngularJS?

I am looking to retrieve the HTML page as a string after AngularJS has finished rendering the template. My goal is to send this content to the server. .controller('MyCtrl', ['$scope', '$location', function ( $scope, $location ...

JavaScript - The left dropdown menu stubbornly remains visible when clicked in white space, unlike the right dropdown which disappears as expected. Puzzled by this inconsistency

Whenever I click on the selection criteria box, a dropdown menu appears. Clicking on the white space or the data table button makes the drop-down menu disappear, which is good. However, when I perform the same action for 'choose data table,' the ...

Using environmental variables in Nuxt 2 or Nuxt 3 - a step-by-step guide

I have an .env file located in the root of my project. In my nuxt config, I am using variables to configure ReCaptcha as shown below: import dotenv from 'dotenv' dotenv.config() export default { modules: [ ['@nuxtjs/recaptcha&ap ...

Merge the tap and doubletap Ionic events together

I have searched through a few examples, but I have not found anything that solves my problem. Here's what I need help with: I am trying to create an element that has two separate events - one for a single tap and another for a double tap. However, the ...

Learn how to dynamically insert an element into an angular scope using a click event

Currently, I am working on a function called onGroundUserClick within the Scope passedScope. The goal is to have a function triggered upon the completion of loading the iframe that will establish ng-click. var $tdName = $("<td/>", { ...

The outputs of base64(sha256(data)) from nodejs crypto and CryptoJS are showing discrepancies

In my setup, I have a node server and a react-native app. The node server utilizes the crypto module for all cryptographic operations, while the react-native app relies on the crypto-js library due to the unavailability of crypto. You can find a sample co ...

A comprehensive guide on effectively monitoring Form Abandonment in Google Analytics using jQuery or JavaScript

Is it possible to accurately track "Form Abandonment" in Google Analytics using jQuery or JavaScript? This method can help generate reports that display how far users progress through form filling before exiting or failing to submit. Are there more effect ...

Unable to see media queries on desktop by default, but can easily view them by inspecting the page

As I delved into a tutorial on media queries, I encountered a perplexing issue. Upon opening the HTML file in Chrome or Firefox, all I saw was a blank page with no content displayed. However, upon inspecting the page, the code appeared as expected and I co ...

Having trouble retrieving the input value using JavaScript

I have been attempting to retrieve the value of an input tag using JavaScript and display it on the console, but my code seems to be not functioning properly. Can someone help me identify the issue in the following code snippet? const userTextValue = doc ...

Leveraging Json data in Angular components through parsing

I am currently developing an angular application where I need to retrieve and process data from JSON in two different steps. To start, I have a JSON structure that is alphabetically sorted as follows: { "1": "Andy", "2": &qu ...

Opting for pre-selected default data within Material UI's select component

When utilizing the select component in Material UI, I am tasked with passing data as props to set a default selected value. The parent component provides the coursename prop, which can be accessed through this.props.coursename. I want this passed course to ...

The process of uploading images to a server by making an AJAX call to a PHP file

I have an input file and I want to upload the attached file to the server with a message saying "uploaded successfully" when I click on the upload button. However, I am getting a "file not sent" message. (The uploaded images need to be saved in the uploa ...

Submitting a form that was loaded using jQuery cannot be done with jQuery

After successfully using jQuery to load a form from the sidebar to the main page, I encountered an issue with submitting the form using jQuery as well. Although I have previously used the same jQuery code to submit forms that were not loaded with jQuery, t ...

Is it possible to display a website page that includes X-Frame-Options: deny in its header response using ReactJS?

I am attempting to display a webpage with the X-Frame-Options: deny setting in a React application. Since I cannot utilize the <iframe> element, I am exploring alternative methods to render the page. Unfortunately, modifying the server side configu ...

The variants array in VUE.js is not displaying properly

I have recently been delving into vue.js for my work and encountered a significant issue. I wanted to create a simple TODO application. In my index.html file, I only have a div for a header and a root div with an ID: #app. Inside the root div, there is a ...