Fizzy beverage with right alignment

Why are the sprites in my #tbr div aligning to the left even though its align is set to right? Any suggestions?

Regular text, links, and images seem to be working correctly (aligned to the right with a 20px right margin as intended).

HTML:

<div id="topbar">
<div id="tbl>abc</div>
<div id="tbc">center</div>
<div id="tbr">
<div id="bar">
<a href="#" id="sound"></a>
</div>
</div>
</div>

CSS:

#topbar {
    width:100%;
    height:36px;
    padding-top:12px;
    background-color:#e7e6e6;
    border-top:1px solid #d0cdcd;
    border-bottom:1px solid #d0cdcd;
}

#tbl {float:left;width:30%;text-align:left;padding-left:20px;}
#tbc {display:inline-block;text-align:center;width:30%;}
#tbr {float:right;width:30%;text-align:right;padding-right:20px;}

#bar {margin-top:-5px;}

#bar a {
    height:35px;
    display:block;
    background-image:url(http://goo.gl/yLbQ9);
    float:left;
}

#sound {width:35px;background-position:0 0;}

JSFIDDLE: http://jsfiddle.net/B4n9T/

Answer №1

It's a little unclear if I fully understand your explanation, but it seems like this could be the problem:

#bar a {
    height:35px;
    display:block;
    background-image:url(http://goo.gl/yLbQ9);
    float:left; //you want this to be right
}

Answer №2

Check out the solution here

This is the updated fix:

I added position:relative; to #tbr and also set width:auto; to prevent it from being incorrectly positioned again.

Answer №3

To align your #bar a to the right, simply add float:right like so:

#bar a {

    height:35px;
    display:block;
    background-image:url(http://goo.gl/yLbQ9);
    float:right;
}

Hopefully this solution works for you. Check out the demo here:- http://jsfiddle.net/B4n9T/5/

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

Determine if two JavaScript strings are anagrams of one another by comparing their characters. What specific method or approach is utilized in this scenario?

Could someone please provide a breakdown of the JavaScript code logic used here? The following code is designed to check if two strings are anagrams of each other, but I'm having trouble understanding the approach taken to perform this check. Any he ...

Issue with Bootstrap modal not closing automatically after submitting an ajax form

I am facing an issue with a modal on my page that is used for submitting courses registered by students. Even after successful submission, the modal closes but leaves behind a faded background. I have attempted various solutions from StackOverflow without ...

Chrome clipping positioned spans

Having trouble positioning a label above inline sections with spans in Chrome, as the labels are getting clipped oddly. Check out these screenshots: Firefox view: Chrome view: In the Chrome screenshot, you can see that the labels are being cut off based ...

Looking to enhance current CSS3 organizational chart by adding a second primary level

I'm having difficulty trying to replicate the first-level (director) box with a vertical line in between. The original chart only has one level with subs below. Take a look at the image provided to see the desired outcome... You can find the CodePen ...

Utilizing the <style scoped> feature within my Angular template

When adding CSS styles in the specified htm file's templateUrl while loading a directive, I wonder if this is a bad idea. Will it be repeated every time the template is instantiated on the rendered page, or does Angular handle this differently? By usi ...

Divergent font sizes displayed in Ubuntu Chrome and Firefox with Bootstrap 4

I recently started working on a website using Ubuntu. However, I noticed that when I view it in Firefox, the layout appears smaller compared to Chrome. Here are screenshots for reference: https://i.sstatic.net/YnMFL.jpg https://i.sstatic.net/Jespf.jpg B ...

Tracking the progress of reading position using Jquery within an article

Here is an example of a reading progress indicator where the width increases as you scroll down the page: http://jsfiddle.net/SnJXQ/61/ We want the progress bar width to start increasing when the article content div reaches the end of the article c ...

css does not bind borders with rounded limits

Is there a way to make the bottom border rounded at the ends? I want the solid line to have rounded edges, but it's not working with my current table code. <p-table [value]="fg?.controls?.treesSummary?.controls" styleClass="sumTable& ...

After using `setAttribute`, React is unable to produce any audio

Currently, I am facing an issue with a React component where it should play sound from an array of IDs stored in the database by setting the ID to the src attribute for the source tag. However, this functionality is not working as expected. Interestingly, ...

Parsing of the module failed due to an unexpected character appearing when trying to insert a TTF file into the stylesheet

As a newcomer to Angular, I recently completed the tutorial and am now working on my first app. While trying to add an OTF file, everything went smoothly. However, when I made a change to my app.component.css file and included this code snippet: @font-fa ...

How can I create a customized placeholder effect for the Paytm login page text box?

Looking to create a placeholder effect on the text boxes for a Paytm login page? https://i.sstatic.net/sox0a.png ...

Mastering @media queries to dynamically alter widths in prop styled components

I have a unique component that utilizes an object with its props for styling. const CustomSection = ({ sectionDescription, }) => { return ( <Text {...sectionDescription} content={intl.formatMessage({ id: &apos ...

Is it possible to dynamically center align an image based on varying column widths in Bootstrap 4?

Hello everyone, I am currently working with Bootstrap 4 and have a column containing an image as shown in the code snippet below: <div className='col-xs-12 col-sm-5 col-md-4 col-lg-3'> <img src={movie.Poster} className='movie ...

Disable the button on smaller devices

I'm trying to make my button take up the full width on smaller screens like mobile devices. Here's what I have so far... Large Device https://i.sstatic.net/TJex1.png Medium Device https://i.sstatic.net/Hvkan.png Small Device https://i.sstatic ...

What is the best way to position a title at the bottom center of each image within my grid gallery?

I'm struggling to find a way to position a title at the bottom of each image in my grid gallery, right in the center of the photo with a light-gray background. I want the text to be fully visible regardless of the image used. Currently, I can only put ...

Expansive Offspring Division stretching to the Entire Vertical Length of its Guardian Division

I'm attempting to achieve full coverage of the parent div section by my child div section. Take a look at the Example URL (specifically where the Canadian Flag Stand Up Paddle Boarders are located) towards the bottom: Essentially, when I set the widt ...

Styling a fixed sidebar in Vue.js

I am currently working on a layout design that includes a fixed sidebar on the left side, positioned beside a container with its own grid structure. Utilizing Vue.js means each template contains <div> elements where I attempt to incorporate additiona ...

"Resolving the issue with unnecessary line breaks in Optimizepress when input is contained within a paragraph

I am experiencing an issue with the code on my server: <p>This is a test to determine why the <input type="text" style="text-align: center;" value="input"/> element appears on a new line when displayed on a wordpress page.</p> When view ...

Dynamically created span element in script facing issues in MVC application

I have a single MVC project where, in the BusinessPosition.cshtml file, I am dynamically creating a tree view at runtime. By default, it displays the main child of the root node upon page load, like this: <ul class="col-lg-20 col-sm-12 col-xs-12" style ...

Detecting the directional scrolling on a page with the rubber band effect disabled

html { height: 100%; width: 100%; overflow: hidden; } body{ margin: 0; min-width: 980px; padding: 0; height: 100%; width: 100%; overflow: auto; } In order to prevent macOS rubber band scrolling and detect the scroll directi ...