Reposition the div element on mobile devices using media queries

Hello, I'm facing an issue on mobile with my website: dev site

Today, I implemented a dropdown menu with flags to allow language switching. However, the dropdown in mobile is appearing under the hamburger nav bar. I was thinking of using media queries to address this as it only happens in mobile. Can anyone provide some help?

Below is the code snippet:


<div class="navbar-header">
    <button type="button" id="navbar-toggle" class="navbar-toggle" data-toggle="collapseX" data-target=".navbar-responsive-collapseX"
    style="margin-top: 0px;">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
    </button>
</div>


<!-- Code for flag dropdown menu -->

<!-- Positioning the dropdown in the navbar -->
<div class="image-dropdown" id="image-dropdown" style=" float: right; position: relative; top: 30px;width: 45px;">

    <a href="http://www.uprightpose.com/">
    <input checked="checked" type="radio" id="line1" name="line-style" value="1" onclick='window.location="http://www.uprightpose.com/";' />
    <!-- Hyperlink to the language page -->
    <label for="line1"></label>
    </a>

    <a href="http://www.uprightpose.com/home-es-new/">
    <input type="radio" id="line2" name="line-style" value="2" onclick='window.location="http://www.uprightpose.com/home-es-new/";' />
    <label for="line2"></label>
    </a>
</div>
<!-- End of flag dropdown menu -->

and here is the CSS:


<style>
#image-dropdown {
/* Styling the "box" in its minimized state */
    width:80px; height:50px; overflow:hidden;
    /* Animating collapsing the dropdown from open to closed state (very fast) */
    -moz-transition: height 0.1s;
    -webkit-transition: height 0.1s;
    -ms-transition: height 0.1s;
    -o-transition: height 0.1s;
    transition: height 0.1s;
}
#image-dropdown:hover {
    height:200px;
    -moz-transition: height 0.5s;
    -webkit-transition: height 0.5s;
    -ms-transition: height 0.5s;
    -o-transition: height 0.5s;
    transition: height 0.5s;
}
...
...
...

Answer №1

If you want to position the elements next to each other, try using float:right on both elements and place them within the same container. I've made some adjustments inline due to limitations in modifying with DEV tools.

<div class="image-dropdown" id="image-dropdown" style="float: right; position: relative; top: 30px; width: 45px;">

  <a href="http://www.uprightpose.com/">
    <input checked="checked" type="radio" id="line1" name="line-style" value="1" onclick="window.location=&quot;http://www.uprightpose.com/&quot;;">
    <label for="line1" style=""></label>
  </a>

  <a href="http://www.uprightpose.com/home-es-new/">
    <input type="radio" id="line2" name="line-style" value="2" onclick="window.location=&quot;http://www.uprightpose.com/home-es-new/&quot;;">
    <label for="line2"></label>
  </a>
</div>

<div class="navbar-header" style="display: inline-block;float: right;">
    <button type="button" id="navbar-toggle" class="navbar-toggle" data-toggle="collapseX" data-target=".navbar-responsive-collapseX" style="margin-top: 0px; position: relative;top: 30px;">
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
    </button>
</div>

This layout should align both elements side by side, especially on narrower screens:

https://i.stack.imgur.com/sFqAI.png

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

The Github API checks are currently not properly parsing style attributes when given in the form of HTML within comment text

I have integrated github's create check run API to create a check run for my pull request. The JSON structure I am using for the request body is as follows: { "name" : name, "head_sha" : script.env.CI_COMMIT_SHA, ...

Having trouble positioning text alongside a checkbox in Bootstrap v3.3.6?

Dealing with the alignment of checkboxes in Bootstrap forms is driving me crazy. It seems to look almost perfect on both Chrome and IE on my desktop, where the text and checkbox are aligned almost perfectly. However, when I view it on Chrome on my tablet ...

Ways to center items in a row-oriented collection

When dealing with a horizontal list, the issue arises when the first element is larger than the others. This can lead to a layout that looks like this. Is there a way to vertically align the other elements without changing their size? I am aware of manual ...

The Popover style from React-Bootstrap seems to be missing when applied to my component

Attempting to incorporate a Popover with overlay trigger from React - Bootstrap has proven to be quite the challenge. If you check this image, you'll see what it's supposed to look like. This is the code I used: var {Button, Overlay, OverlayTr ...

Utilizing Electron to save editable user data in a .txt file

I am making an electron app that converts data from .txt files to Javascript arrays. This data is stored inside a folder called faces in the main directory. I also have a button in my app which, when clicked opens file explorer at the faces folder so the u ...

modern marquee

I have implemented a marquee tag that displays news from my database. In order to keep the marquee up-to-date without refreshing the entire page, I utilized ajax (update_panel + timer). However, I am encountering an issue where the marquee does not continu ...

Creating a scrolling effect similar to the Nest Thermostat

After researching countless references, I am determined to achieve a scrolling effect similar to the Nest Thermostat. I came across this solution on this JSFiddle, but unfortunately, the parent element has a fixed position that cannot be utilized within my ...

In what ways can I incorporate Django template tags into my JavaScript code?

I've encountered an issue with implementing my model data into a FullCalendar library template in JavaScript. Despite seeing others do the same successfully, I keep getting errors as the template tags fail to register properly. <script> documen ...

Adjust the color of the font icon within a button when hovering over it

On the bottom of my website (still in development) , there are 3 buttons with an arrow icon preceding the text. The arrow is created using an icon font and I would like it to change color (along with the button text) when hovered over. Any suggestions on ...

Design a layout consisting of a grid with items that maintain a set maximum width while being evenly distributed across the entire width of the device

I'm trying to create a grid with 2 rows and 3 columns, each cell having an image with a max-width of 512px. I added margin to the grid but now the cells are larger than the content. How can I achieve the same visual appearance as flexbox's justif ...

Utilizing Python's Requests Library to Submit a Form without Specifying Input Names

My task is to perform a POST request using the Python Request module. However, I am facing an issue where the input I need to work with only has an id attribute and no name attribute. Most of the examples I have come across involve using the name attribute ...

Employ CSS flexbox and/or JavaScript for creating a customizable webpage

I am in the process of developing a basic IDE for an educational programming language that has similarities to Karel the Dog. One major issue I am encountering is creating the foundation HTML page. The IDE consists of 4 main areas: Toolbox (contains but ...

Simulating a mobile device screen size using an embedded iframe

Imagine this scenario: What if instead of adjusting the browser window size to showcase a responsive web design, we could load the site into an IFRAME with the dimensions of a mobile screen. Could this concept actually work? Picture having an IFRAME like ...

Unable to hide the mobile menu button

I am currently working on a fun website project . I am facing an issue with the mobile menu button not disappearing using display:none in Safari on my iPhone when in landscape mode, even though it works fine in Chrome. My goal is to make the #menu-button ...

Is there a way to create an <a> element so that clicking on it does not update the URL in the address bar?

Within my JSP, there is an anchor tag that looks like this: <a href="patient/tools.do?Id=<%=mp.get("FROM_RANGE") %>"> <%= mp.get("DESCRITPION") %></a>. Whenever I click on the anchor tag, the URL appears in the Address bar. How can ...

Facing challenges with parsing JSON files in an Angular 2+ application

Utilizing the Angular CLI, I have configured this project with the standard folder layout. My goal is to practice reading a JSON file from src/app/assets/items.json and then using it to display these items in the HTML. items.json: { "results": [ ...

Conceal or reveal buttons using JavaScript

I am struggling with a function that is supposed to hide certain buttons and create a new button. When I click on the newly created button, it should make the previously hidden buttons visible again. However, the function does not seem to work properly. ...

mobile-responsive vertical alignment using Bootstrap

Here is a jsbin that demonstrates the issue and here is the markup: <div class="row"> <div class="col-sm-4 xs-12"> <strong>UK Postcode</strong> </div> <div class="col-sm-4 xs-12"> <strong>Other Fie ...

The push action in NavController is not displaying Google Maps as expected

Trying to display a map upon clicking a button is proving challenging for me. It appears that the function NavController.push() does not work as expected, while NavController.setRoot() does. Despite not encountering any errors, I am unable to identify the ...

The Navbar's Toggle Icon Causes Automatic Window Resize

I implemented a mobile navigation bar using React and JS that slides in from the left when clicked. However, I encountered two issues: whenever I click on a menu button in the navbar or when my ad carousel moves, the window resizes for some reason. Additio ...