Images that float to the right can escape the boundaries of their div container

I'm struggling to find a solution for my current HTML setup. Here's what I have:

<script> 
$(document).ready(function(){
  $("#flip").click(function(){
    $("#panel").slideToggle("slow");
  });
});
</script>

<style type="text/css"> 

</style>
</head>
<body>
    <div id="flip">
        <p>Click to slide the panel down or up</p>
        <img class="ux" src="/path" alt="complete" height="32" width="32" align="right" />
        <img class="ux" src="/path" alt="add" height="32" width="32" align="right" />
        <img class="ux" src="/path" alt="edit" height="32" width="32" align="right" />
        <img class="ux" src="/path" alt="remove" height="32" width="32" align="right" />
    </div>
    <div id="panel">Hello world!</div>

CSS:

body {
  width: 80%;
  margin: auto;
  margin-top: 30px;
}  

#panel,#flip
{
    padding:5px;
    text-align:center;
    background-color:#e5eecc;
    border:solid 1px #c3c3c3;
}
#panel
{
    padding:50px;
    display:none;
}

Currently, the images appear at the bottom right corner of the div border and shift when slideToggle() is activated. My goal is to have all 4 images aligned inline with the paragraph tag. Any assistance would be appreciated.

EDIT: The jfiddle link for reference: http://jsfiddle.net/4jNp8/

EDIT: Same JSFiddle but with placeholders: http://jsfiddle.net/4jNp8/1/

Answer №1

To make the p and img tags display inline, simply add display:inline block to them:

#flip > * {
    display: inline-block;
}

The p tag is a block level element by default, so in order for it to display inline with other content, you need to use inline-block or some other positioning like float or display: table-cell.

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

When I employ ngroute, the Angular section in the html page does not display

I am looking to implement a fixed menu named "fixed_admin.html" on my website: <!DOCTYPE html> <!-- saved from url=(0069)https://hackerstribe.com/guide/IT-bootstrap-3.1.1/examples/dashboard/ --> <html lang="en"><head><meta htt ...

Troubleshooting error: Unable to access property 'post' in Angular Service when using $http

As I delve into learning Angular, my approach involves shifting all the business logic to services. However, I encountered an error while attempting a post request within a service: Cannot read property 'post' of undefined Provided below is a ...

Identifying input fields using XPath depending on their associated labels

I'm trying to figure out why an XPath query I found returns multiple results when selecting an input based on its label. The first XPath query I used, //input[@id=(//label[.='Max Driving Time_h']/@for)], retrieves 3 inputs even though only o ...

Style your Checkbox Button with the Checkbox component from Element Plus

Currently, I am utilizing Vue 3 along with the Element Plus library. My goal is to modify the hover, active, and select colors of the Checkbox Button that I have implemented. Unfortunately, my attempts to do so have not been successful. I essentially copie ...

Is it possible to customize the appearance of the selected item in a select box? Can the selected value be displayed differently from the other options?

My current project involves working with the antd' select box. I have been trying to customize the content inside the Option which usually contains regular text by incorporating some JSX into it. The output currently looks like this: https://i.sstati ...

What factors could potentially cause Internet Explorer to fail in processing conditional comments effectively?

I am currently developing JSP pages with Tomcat and I need to ensure compatibility with IE 7, as requested by the client, along with Firefox and Chrome. Despite including both sets of code in my program, it seems to work perfectly fine for browsers other ...

Extract the text from an html element by utilizing xpath

This snippet contains HTML content <p class="ref Hover"> <b class="Hover Hover Hover Hover Hover">Manufacturer Part Number:</b> MC34063ADR2G<br> <b>Mounting Method:</b>&nbsp; Surface Mount& ...

Tips for adjusting the color of multiple <a> tags?

One issue I am facing is the color of the .row a element impacting my contact link, making it white. Despite attempting to change it to red, the color remains unchanged, but upon hovering it turns green. .row a { color: white; text-decoration: non ...

Tips for integrating three-dimensional JSON models from ThreeJS into A-frame

Looking to incorporate some low poly models from into a ThreeJS JSON model in A-frame. This method is preferred due to its efficiency and smaller file size, resulting in faster loading times. However, there seems to be a lack of guidance on how to achieve ...

What is the best way to display all checked checkboxes even when the page is reloaded?

I am facing an issue with my website - it is using JavaScript to search for checked checkboxes. $(function () { var $allELements = $('.input-box'); var $selectedElementsListing = $('#selectedElements'); var $selec ...

Enhance the efficiency of IE driver within Selenium1

Recently, I've noticed that Selenium1 performs really well with Firefox using XPath, but it's extremely slow with IE. Is there a way to improve the performance of Selenium1 in IE? I've heard that some people use JQuery element locators in S ...

jQuery's z-index feature is malfunctioning

When I hover over my menu, a box fades in. However, there is a small icon behind this box that I want to move to the front so it can be visible during hover. To see an example of my menu, click here: Navigation I attempted to address this by using jQuer ...

Do all links need an href attribute?

I'm inquiring about this because I have specific links that function as buttons to retrieve content through ajax, eliminating the need for href tags. (This inquiry is driven by SEO considerations) ...

Troubleshooting problem with JSON decoding in PHP and json_encode

Encountering an issue when parsing JSON received from a PHP backend. In my PHP code, I have an array that I send using json_encode: $result[] = (object) array('src' => "{$mergedFile}", 'thumb_src' => "{$thumb_file}"); echo json_e ...

Error encountered while attempting to submit a form through jQuery Ajax

I am encountering an issue with receiving a response from the server while using jQuery Ajax. My goal is to upload a file using Ajax, but the following lines of code do not seem to be functioning correctly: <script language="javascript" src="jquery-1.7 ...

The listener is not activating the AJAX function

It seems like the function validate() is not being called in the listener, causing an error and preventing data from being added to the database. Here is the code snippet from index.php: <!DOCTYPE html> <html> <head> <title>< ...

Loading data using AJAX for insertion during page load

I'm attempting to insert data into a database using PHP, but I'm struggling to figure out how to accomplish this task. Despite conducting searches on Google, I have yet to find a suitable solution. Here is my Ajax code: if(window.location == "p ...

What steps do I need to take in order to make the navbar-collapse function properly with an animated

After successfully implementing a collapsible navbar with a hamburger icon for mobile view, I decided to add some extra styling and animation to the hamburger button. However, now the hamburger button remains visible even in desktop view, which is not what ...

What is the best way to trigger the code within my useEffect React hook to execute again upon refreshing the page?

I'm encountering an issue where the value of states is becoming 'undefined' after refreshing the page. Within my useEffect hook, I am generating a random number to select a question object from an array. Everything works smoothly on the ini ...

Linking Two HTML Components in Angular 4 with Identical Values

Recently, I've started working with Angular and encountered an issue. In a table row, the value item.md_id is bound like this: <tr *ngFor="let item of driverData"> <td class="align-right" id="md_id" [(ngModel)]="item.md_id" name="driverId ...