Difficulty encountered in setting the width of a sticky bottom element to be located at the bottom of the page with Tailwind

Fiddle: https://play.tailwindcss.com/pvT1jW8zZd

Here is the code snippet I am working with:

Here is how it currently appears:

https://i.sstatic.net/2SRny.png

<div class="bg-yellow-300">

<div class="p-16 m-5 text-xl  bg-gray-500 ">
  Koalas are quite interesting animals. What sets them apart is their small brain to body ratio and the fact that their brains are smooth. Unlike other mammals, koalas have smooth brains which limits their cognitive abilities. 
...
In summary, koalas may not be the smartest creatures and are known to have various health issues. Despite this, their cuteness is appealing to many despite their unique physical features.
</div>

    <div class="bg-blue-500 sticky text-xl   bottom-5 right-5
     
           rounded-lg  p-5 ">
         <a >UP</a>
     </div>

</div>

However, I would like it to appear like this instead:

https://i.sstatic.net/nVMPK.png

How can I achieve this layout? I am seeking to adjust the button width to fit the content ('UP') and the specified padding.

Answer №1

align it to the right (using the class float-right)

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<div class="bg-yellow-300">

<div class="p-16 m-5 text-xl  bg-gray-200 ">
  Koalas are incredibly unpleasant creatures. They possess one of the smallest brain to body ratios among mammals, and their brains are notably smooth. A folded brain increases surface area for neurons, but koalas lack this feature. They cannot adapt their feeding behavior and can starve in the presence of abundant food. Their dietary staple, eucalyptus leaves, are both toxic and low in nutrients, forcing koalas to ferment them for days to extract minimal sustenance. Koalas have evolved a hind gut with a substantial body ratio, but their teeth wear down quickly on their diet. In severe cases, koalas starve due to dental erosion. The young are raised on nutrient-poor milk and must transition to eucalyptus leaves, which they struggle to digest due to a lack of gut flora. To aid in digestion, joeys consume partially digested fecal pap from their mother's anus. Additionally, koalas suffer from high rates of chlamydia and exhibit aggressive behavior, including rape. Their brains have an excess of cerebrospinal fluid to protect them from falls, showcasing their lack of intelligence. In summary, koalas are unintelligent, disease-ridden creatures with horrifying anatomical features.
</div>

    <div class="bg-blue-500 sticky text-xl float-right  bottom-5 right-5

           rounded-lg  p-5 ">
         <a >UP</a>
     </div>

</div>

Alternatively, use inline-block and text-align

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<div class="bg-yellow-300">

<div class="p-16 m-5 text-xl  bg-gray-200 ">
  Koalas are incredibly unpleasant creatures. They possess one of the smallest brain to body ratios among mammals, and their brains are notably smooth. A folded brain increases surface area for neurons, but koalas lack this feature. They cannot adapt their feeding behavior and can starve in the presence of abundant food. Their dietary staple, eucalyptus leaves, are both toxic and low in nutrients, forcing koalas to ferment them for days to extract minimal sustenance. Koalas have evolved a hind gut with a substantial body ratio, but their teeth wear down quickly on their diet. In severe cases, koalas starve due to dental erosion. The young are raised on nutrient-poor milk and must transition to eucalyptus leaves, which they struggle to digest due to a lack of gut flora. To aid in digestion, joeys consume partially digested fecal pap from their mother's anus. Additionally, koalas suffer from high rates of chlamydia and exhibit aggressive behavior, including rape. Their brains have an excess of cerebrospinal fluid to protect them from falls, showcasing their lack of intelligence. In summary, koalas are unintelligent, disease-ridden creatures with horrifying anatomical features.
</div>

    <div class=" sticky text-xl bottom-5 mx-5 text-right">
         <a class="inline-block rounded-lg  p-5 bg-blue-500">UP</a>
     </div>

</div>

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

Making the dropdown width of the shiny selectInput customizable

Inspired by a discussion on Stack Overflow, this code snippet prevents dropdown text wrapping and sets the width for all dropdowns. Is it possible to individually adjust the width of each dropdown created with selectInput? library(shiny) ui <- (fluid ...

Is it possible to utilize CSS to form a triangle outline on the right-hand side of a Bootstrap list group?

https://i.sstatic.net/vSoa0.png Hey everyone! I'm trying to achieve a triangle shape using CSS at the end of a list item. I've utilized the list group component from Bootstrap to display my list. Below is a snippet of my code. I've als ...

The JavaScript script to retrieve the background color is malfunctioning

I am currently working on developing a highlighting feature for an HTML table that will dynamically change the row colors on mouseover. Below is the code snippet I have been using, but it seems to be experiencing some issues. Any assistance would be greatl ...

Trouble with JavaScript preventing the opening of a new webpage

I need help with a JavaScript function to navigate to a different page once the submit button is clicked. I have tried using the location.href method in my code, but it's not working as expected. Even though I am getting the alert messages, the page i ...

Modify the icon in the header of MaterializeCSS Collapsible when it is opened

I'm struggling to figure out how to change the icon of a toggled collapsible element. I have been reviewing their documentation but am having trouble making it work as intended. $('.collaps_roles_permission').collapsible({ accordion: tr ...

What is the most efficient way to evenly separate a CSS3 gradient?

Is there anyone who can assist me in achieving an even gradient break? body { height: 2500px; background: -webkit-linear-gradient(#000000 1%,#FFFFFF 1%,#FFFFFF 13%,#2ecc71 13%,#2ecc71 30%,#3498db 30%,#000000,#FFFFFF,#34495e); } I've been att ...

When a CSS fluid layout includes a containing div with margin or padding, it may lead to

On my jsfiddle , the outermost wrapper div has a width of 100%. I am trying to create an inner div (tb_margin or tb_padding) where the content starts 40px from the left. I have attempted to use both margin and padding for this left spacing, but in both cas ...

Looping through mysql data horizontally within a div tag

Looking for assistance to create a content loop similar to the one on this website? I attempted to use a while() loop, but it ended up displaying vertically without using a table. I suspect this page utilizes thumbnails. What I aim for is to have the it ...

Using Node.js to send instructions to an HTTP server in order to highlight or add color to specific elements within

I have set up a server that receives data from a gaze sensor, as well as an HTTP server that serves an HTML page. I am looking for a way to dynamically highlight elements in the HTML based on the incoming data. Any suggestions on what resources or techniqu ...

The border class in Bootstrap 4 seems to be malfunctioning when it comes to the top

I'm struggling to add a border to a div using Bootstrap 4. When I try using only the border property, it looks strange, and when I use other properties, no border appears. Here is the code snippet: I even tried with the beta 2 version. If there is s ...

AngularJS enables you to easily manipulate image width and height using the ng-file-upload feature

Seeking assistance with validating image width and height based on a 1:3 ratio prior to uploading using ng-file-upload. The validation should occur before sending the image to the server. Unsure how to retrieve the dimensions of the selected image for val ...

Is it possible to represent a recursive variable using CSS?

When it comes to the html structure: <body> <div> <div> <div> ... </div> </div> </div> </body> Is there a method to create recursive variables that utilize their parent's value: body ...

Ensure that the top of a div stays in place as the user scrolls, and spans the entire width of the div

My goal is to create a sticky or fixed position header inside a div with a list, but I'm facing an issue where it only sticks to the width of the text. If I expand the width to 100%, it takes up the size of the entire page: import styled from 'st ...

Simplified user interface for detecting radio button clicks

Currently working on a form that includes radio buttons, where an update function is triggered whenever there is a user input change. The challenge I am facing is how to incorporate user-friendly radio buttons with a larger button area encompassing both t ...

CSS - selecting elements that are greater than a specific criteria N

I have multiple <p> tags in the body of my HTML. I want to display only the first two paragraphs and hide all the paragraphs that come after. However, the code I'm using doesn't seem to work as expected. <html> <head> < ...

Setting the dimensions of an HTML - CSS block

I am trying to style a navigation bar using the following CSS code: #nav {} #nav a { position: relative; display: inline-block; color: #F0F0F0; width: 1em; height: 2em; line-height: 0.9em; } #nav a.ic ...

Break the page after generating specific charts with JQuery

I have a task to create multiple charts, where the first page needs to include a header and the first 8 charts. How can I insert a page break after the 8th chart and move on to a second page without a header? Each student has different subjects and score ...

How can I emphasize only a portion of a word in ReactJS and Material UI?

I am attempting to replicate this design: https://i.stack.imgur.com/H8gKF.png So far, this is what I have been able to achieve: https://i.stack.imgur.com/TJXXb.png My project utilizes Material UI and ReactJS. Below is a snippet of the code: bodyTitle: { ...

Adjusting the Height of the Video Jumbotron in Bootstrap

One of my main goals is to create a jumbotron with a video that plays, occupying 100% width and 70% height of the screen. However, I am facing an issue where the video follows the scrolling behavior when I don't want it to. Specifically, as I scroll d ...

retrieving embedded content from an iframe on Internet Explorer version 7

Need help with iframe content retrieval $('.theiframe').load(function(){ var content = $(this.contentDocument).find('pre').html(); } I'm facing an issue where the iframe content is retrieved properly in FF, Chrome, and IE 8,9 ...