Utilizing inline-block for styling code blocks

I'm attempting to format two blocks with varying lengths using inline-block, but block-1 is getting aligned with the length of block-2. I need to keep the height of block-1 at 100px.

Check out this jsfiddle for reference:

http://jsfiddle.net/CGHZ5/5/

Here's the HTML code:

<div id="id1">
    <div id="id1-test">
    </div>
</div>
<div id="id2"></div>

And the CSS styling:

#id1-test{
    background-color: red;
    float: right;
    height: 15px;
    width: 10px;
}

#id1{
    background-color: blue;
    display: inline-block;

    height: 100px;
    width: 200px;
}
#id2{
    background-color: green;
    display: inline-block;

    height: 200px;
    width: 300px;
}

Answer №1

Opt for floats over using display:inline-block

Answer №2

Make sure to update your CSS as shown below:

    #id1-test{
    background-color:red;
    float:right;
    height:15px;
    width:10px;
}

#id1{
    background-color:blue;
    display:block;
    float: left;
    height:100px;
    width:200px;
}
#id2{
    background-color:green;
    display:block;

    height:200px;
    width:300px;
    float: left;
}

The changes provided will meet the requirements in your fiddle.

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

I am encountering an issue with my jQuery datatable where the amount column only displays rounded values. I would like for the values to appear in currency format, such as $233.25,

I'm facing an issue with my jQuery datatable where the amount column displays only round values instead of the desired currency format like $233.25 showing up as $234. Here is the HTML table head section: <thead> <tr> <th> ...

the comment in vuejs is not being identified as a comment properly

I came across an issue with comments not being recognized in my vue js code. I attempted to comment out 4 @click events in radios while testing something, but it resulted in an error for each of them. The error message I received was: https://google.com/#q ...

HTML links have been disabled

I have been making updates to the charity website I manage, heroinitiative.org. You can view the revamp progress here: (please note that this is not live code, it is simply for my boss to see the progress and does not need to be kept secret, hence why I a ...

Function for jQuery Slide Toggle is not being invoked

I'm struggling with jQuery Slide Toggle. $(document).ready(function() { $("a").click(function() { $(this).parent().parent().children("p").Toggle(400); return false; }); }); I have multiple posts displayed on the page fetched from ...

Creating movement in an SVG patterned background

Currently in the process of designing a brand new website using NextJS and Tailwind. I am looking to incorporate an infinitely translating background effect that moves towards the bottom right, similar to this example (but with my own unique pattern): htt ...

Utilizing Bootstrap's hidden command to pinpoint specific titles

Here is the code I have that generates previous and next links for my Wordpress post. I am looking to hide the title of these links and instead display 'back' and 'next' as the text. The current code successfully hides the icon display ...

Discovering the data from a JSON serialization in JavaScript

Within my PrintViewModel list, there is a sublist called Summary. I am working with ASP.NET MVC. @model CRC.Models.PrintViewModel; <label id="lblTotalMonthlyLoanDeduction"></label> I am serializing it using JSON. var obj = @Json.Se ...

Utilizing Fancybox with a polymer paper-card: A step-by-step guide

I have a collection of paper-cards and I am looking for guidance on integrating the fancybox library to display the content of each paper-card. Here is a sample of a paper-card: <paper-card heading="Emmental" image="http://placehold.it/350x150/FF ...

The visibility classes d-none and d-sm-block are not functioning properly on mobile devices or when toggling

I have been attempting to hide a card on mobile devices using the class "d-none d-sm-block". However, while this method works when I resize the page, it does not work on actual mobile devices or when using the toggle device toolbar in Chrome. S ...

Error encountered in PHP due to a spacing issue in the GET

<?php $current_subject = $_GET['subject_id']; $current_content = $_GET['note_id']; echo "<form method=\"post\" action=mainpage.php?subject_id=".$current_subject."&note_id=".$current_content.">"; ?> <in ...

Adjusting the position of the parent div by manipulating the bottom property

Is there a way to toggle the bottom property of a div when clicking its child anchor tag? <div class="nav" :class="{ 'full-width': isFullWidth }"> <a class="toggle-button" @click="toggleNav"><i class="fa fa-angle-down">< ...

What is the method for changing the background color of rows in a grid

Within my asp.net application, I am implementing a grid-view control where I am populating data into a label element within the grid-view. If the data happens to be empty, I want the row color to be displayed in red. However, if there is data to bind ...

The animation on my jQuery script seems to be malfunctioning

I'm encountering an issue with a div element that is partially off the screen and should move out when a button is clicked. I've shared my script here, but it seems to not work as intended when the button is pressed. The visualization in jsfiddle ...

The function window.scrollBy seems to be causing a conflict with jjmslideshow, resulting in the page being unable to

I wrote a simple script to create a "smooth scroll" effect when a specific link is clicked: (function() { 'use strict'; // Checking for compatibility if ( 'querySelector' in document && 'addEventListener' in window ...

What strategies can be implemented to decrease the value of the writing box by 2.5%?

I would like to decrease the value in the input box by 2.5%. Here is the HTML code snippet: <div class="ZakatCalc"> <div class="calcimg"> <img src="" alt="" srcset="" class=" ...

Is it possible to decrease the size of a div by scrolling both vertically and horizontally?

Can a div's height and width both be reduced at the same time while scrolling down a page? Let's say that as the user scrolls, the size of the div changes from 400px by 400px to 200px by 200px, all while remaining centered on the page. I've ...

Scraping data from a website using Python by targeting the `<td

Just starting out with Python and Web Scraping... I'm trying to extract the numbers 1.16, 7.50, and 14.67 from the highlighted portion of code using td, class, table-matches__odds pageSoup.find_all, but so far haven't had any luck. Anyone have an ...

Generate a hard copy of the data table row without needing to view it beforehand

Here are some records from a table: +--------+---------+-------+----------+--------+ | Name | Address | Phone + Email | Action | +--------+---------+-------+----------+--------+ | Andy | NYC | 555 | <a href="/cdn-cgi/l/email-protection" cl ...

Guide to integrating PHP and MySQL with HTML

I am venturing into the world of php for the first time in order to establish a connection with MySQL on my raspberry pi. Both the server and MySQL are up and running on the Pi, and I am seeking to modify my index.html file to display a value stored in the ...

BASH-SHELL SCRIPT: Display a specific portion of content from a file

Recently, I stumbled upon a text file containing a snippet of HTML code: >>nano wynik.txt which includes the following text: 1743: < a href="/currencies/lisk/#markets" class="price" data-usd="24.6933" data-btc= "0.00146882" My goal is to extr ...