html css float:right with image is not functioning correctly

Web Development

<div class='titleStyle' id='mainTitle'>
        <p class='headerText'>Company Logo
            <img class='closeIcon' src='images/close.png'>
            <img class='maxIcon' src='images/max.png'>
            <img class='minimizeIcon' src='images/minimize.png'>
            <img class='settingIcon' src='images/setting.png'></p>
    </div>

Cascading Style Sheets

.icon{float: right;}

Browser Comparison

Looking for Consistent Output across Browsers

Answer №1

To achieve the desired layout, begin by applying float:left to all images and then apply float:right to the container that holds the images.

.foo img{
float:left;//move images next to each other
}


.foo{
float:right;//shift the entire section to the right
}

Answer №2

Visit this link to see an example of giving a bar a width of 800px, placing punch inside a span with a width of 300px floating left, and images within another span with a width of 500px also floating left.

Sample HTML code:

<table class='titleStatus' id='title'>
        <tr>
            <td class='lefttop'></td>
            <td class='bar'>
                <span id="punch">Punch Data</span>
                <span id="close">

                    <img class='minMaxClose' src='images/close.png'>
                    <img class='minMaxClose' src='images/max.png'>
                    <img class='minMaxClose' src='images/minimize.png'>
                    <img class='minMaxClose' src='images/setting.png'>
                </span>
            </td>
            <td class='righttop'></td>
        </tr>
</table>

CSS styling:

.minMaxClose{
    float: right;
}
#close{
    background: purple;
    width: 400px;
    float: left;
}
#punch{
    background: orange;
    width: 300px;
    float: left;
}
.bar{
    width: 700px;
    background: blue;
}

Answer №3

HTML

<table class='titleStatus' id='title'>
        <tr>
            <td class='lefttop'></td>
            <td class='bar'>Punch Data
                        <!--[if IE]>
                             <div class='ico-wrapIE'>
                        <![endif]-->
                        <!--[if !IE]>
                             <div class='ico-wrap'>
                        <![endif]-->
                <img class='minMaxClose' src='images/setting.png'>
                <img class='minMaxClose' src='images/minimize.png'>
                <img class='minMaxClose' src='images/max.png'>
                <img class='minMaxClose' src='images/close.png'>
            </div>
            </td>
            <td class='righttop'></td>
        </tr>
    </table>

CSS

.ico-wrap{float:right;}
.ico-wrapIE {
  position: absolute;
  right: 2px;
  top: 2px;
}

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

What is the best approach to styling a sub-child element within the first child using TailwindCSS?

Currently working with React (Next.js) and TailwindCSS. <ul> <li> <h1 className="bg-red-400">first</h1> </li> <li> <h1 className="bg-green-400">second</h1> </li> &l ...

Missing out on dynamically generated form input information

I've been working on a form using PHP, HTML, and AJAX that is customized for each row in a database table. The form data is sent via Ajax to another page which then uses it to retrieve information from another database based on the input and display t ...

I am unable to click on the navigation buttons in my bootstrap template

I've been working on turning a single page Bootstrap template into a multi-page layout. I duplicated the index page and modified them into services, among other things. Although I updated the href to point to these new pages, the navbar buttons are no ...

Tips on avoiding HTML escaping in Razor (standalone)

I am working with a Model that has a property called Content which stores HTML as a string. var model = new { Content = ... } Razor.Parse(templateBody, model) I am trying to figure out how to render this HTML string using standalone Razor. I attempted: ...

Trouble with executing select query on connected tables in MySQL

$sql=mysql_query("SELECT b.book_id,u.user_id,user_name,book_name,review_date,book_rating,review FROM tbl_books b,tbl_user u,tbl_book_reviews br WHERE b.book_id=br.book_id AND u.user_id=br.user_id ...

Can someone guide me on incorporating a plus/minus feature into Django forms?

What is the best way to integrate this into a Django form? 2/3: 2 represents the currently selected number of items, while 3 is the maximum allowed Note that this form does not interact with the model; instead, it sends data to the Redis server upon cl ...

Expanding a CSS div when the content wraps on smaller screens

When viewing the menu on standard screens, everything looks good. However, on smaller screens, the menu items start to wrap which is fine. The only issue is that the containing div #nav does not automatically enlarge along with it. I would like for the div ...

Unusual trio of divs lined up next to each other

I typically work with tables, but I need to rearrange some div elements by dragging and dropping them. I decided to try a table-less approach this time around. Here's my goal: I want the spacing between all elements to be 24px. My main issue is gett ...

Utilize the .mat-column-name attributes to apply custom styles to a nested component within Angular Material

Within the Child component, an Angular material table is created with columns passed as input: <table mat-table> <ng-container *ngFor="let col of columns" [matColumnDef]="col"> </table> @Input() columns: string[] T ...

The dropdown menu functions smoothly in Firefox, although it may be less consistent in Chrome

I am encountering an issue with my JavaScript drop down menu. It functions properly in Firefox (version 57), but in Chrome (version 62) the drop-down only appears after clicking elsewhere on the page before clicking on the menu icon or button. My code in ...

How to build a login page with a static header and footer using Angular2

For my latest project, I am currently in the process of developing an application using Angular2 and eclipse Neon. Utilizing angular-cli for this app, I am now focused on creating the login page. Within the app.component.html file, you will find the follow ...

One solitary table is successfully loaded

I am facing an issue with my setup where I have two HTML tables and a PHP file that loads every 1 second through AJAX to pass information to these tables. Here is the HTML structure: <div style='float: left;'> <br><br> & ...

Issue with ng-repeat when using radio buttons

While attempting to utilize radio buttons with ng-repeat, I am encountering issues where the form does not bind correctly and all radio buttons are buggy. What could be causing this issue? Whenever I click on a radio button, either all of them change or no ...

Is there a way to prevent elements from resizing when zooming in or out?

What is the best way to prevent elements from resizing on a standard website when users zoom in (CTRL +)? ...

HTML/CSS: Issue with image grid layout where images of different heights are not wrapping correctly

I have a Wordpress-based web project in progress at the following link: The current setup of the post thumbnails grid on the website was done with the assumption that all thumbnails will be the same height. However, I am looking to modify it so that the t ...

What causes the ion-fab-button to not remain fixed within the Ionic 4 popover?

I am currently working on an Ionic 4 application and have implemented a popover feature. Within this popover, I want to include an ion-fab-button that should remain fixed in the top-right corner of the popover. The snippet of HTML code I have written for ...

Inability to showcase text content leads to a div element malfunction

I am seeking assistance in displaying all resulting expressions under the Result and Entered button each time I press "=". I have made some progress but am currently stuck. Any help would be greatly appreciated. Thank you. <!DOCTYPE html> <html ...

What is the best way to ensure grid element takes up 100% of the available height within a flex column

I am working with this HTML structure: https://i.stack.imgur.com/fy5Yz.png My goal is to have the .SceneWithHistory-Container take up 100% of the available height in its parent element. Below is my CSS code: .Module-Container margin-top: 120px; displ ...

What are the steps to achieve form styling using Bootstrap?

I am trying to achieve a specific style using the Bootstrap framework. I have been able to achieve something similar to what I want, but the issue is that the save button is not aligned to the right and is not taking up the available width. There is a gap ...

Applying CSS Style to Element Created in a Vue Component

<template> <div id="body"> <button type="button" @click="create">Create</button> </div> </template> <script> export default { methods: { create () { let e = document.createElement(' ...