Guide to positioning two labels dynamically around an image: one on the right and one on the bottom

I am in the process of creating a visual list of search results and I am struggling with formatting it properly.

.

I have tried to implement the following code for the web form:

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server>
<h2>Search.</h2>
<div class="searchblock" id="searchdiv" runat="server">

    <asp:Button id="TestSearchButton" runat="server" Text="Search the Stuff" OnClick="TestSearchButton_Click" CssClass="btn-default" />

    <asp:TextBox ID="EnterBox" runat="server" Text="Hittin NM"/>

    <hr/>

    <div id="searchResults" runat="server">
    </div>
</div>

The issue arises when trying to display the search results within the 'searchResults' div. Here is the code used to generate these result blocks:

while (i <= allmantemp.Count - 1)
{
    Panel panel = new Panel();
    panel.CssClass = "ResultPanel";

    System.Web.UI.WebControls.Image img2 = new System.Web.UI.WebControls.Image();
    panel.Controls.Add(img2);
    img2.CssClass = "DisplayedImage";
    img2.ImageUrl = "Resources/allmanmushroom.jpg";

    Label numberBox = new Label();
    panel.Controls.Add(numberBox);
    numberBox.CssClass = "ItemNumberResult";
    numberBox.Text = "Item #:" + allmantemp[i].itemNum.ToString();

    Label titleBox = new Label();
    titleBox.CssClass = "ItemTitleResult";
    titleBox.Text = allmantemp[i].title;

    Label descriptionBox = new Label();
    descriptionBox.CssClass = "DescriptionResult";
    descriptionBox.Text = allmantemp[i].description;

    panel.Controls.Add(numberBox);
    panel.Controls.Add(new LiteralControl("<br />"));
    panel.Controls.Add(titleBox);
    panel.Controls.Add(new LiteralControl("<br />"));
    panel.Controls.Add(new LiteralControl("<br />"));
    panel.Controls.Add(descriptionBox);
    searchResults.Controls.Add(panel);

    i++;
}

In addition, here are the CSS classes that are being referenced:

.DisplayedImage{
height: 180px;
width: 180px;
padding-top: initial;
margin-top: 6px;
margin-right: 6px;
margin-left: 6px;
float: left;
}

.ResultPanel{    
margin-left: 210px;
width: auto;
height: 200px;
display: block;
border: solid;
border-color: #DFECE6;
}

.ItemNumberResult{
background-color: #2D2D29;
color: #DFECE6;
margin-bottom: 50px;
margin-top: 10px; 
width: 180px;
}

.ItemTitleResult{
background-color: #2D2D29;
color: #DFECE6;
margin-bottom: 50px;
margin-top: 10px; 
width: 180px;
}

Although the provided code generates the desired result, I am facing challenges in achieving the layout that I envision.

Answer №1

To achieve the desired layout, floating and clearing the code for .ItemNumberResult will shift it below the image while keeping the other content positioned to the right side.

.ItemNumberResult{
    background-color: #2D2D29;
    color: #DFECE6;
    margin-bottom: 50px;
    margin-top: 10px; 
    width: 180px;
    float: left;
    clear: left;
}

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

Tips for emphasizing the letters of the alphabet used in search functionality with Angular

Is there a way to highlight specific alphabets in the searched list instead of highlighting the entire word? Currently, when filtering the memberOffice and memberFacilities lists based on the alphabet entered in the search field, the entire text is highlig ...

Animate custom scrollbars with jQuery for a unique browsing experience

I am experimenting with creating a scrolling animation using mCustomScrollbar Currently, I have managed to obtain the current scrollTop and animate it to a specific height using the code below: $("#content").mCustomScrollbar({ scrollButtons:{ ...

Is it possible that a link with a negative z-index is unclickable in IE11 but functions properly in Chrome, Firefox, and Edge?

I am currently facing an issue with a menu and div content. The problem is that the link in the menu is not clickable on IE 11. What could be causing this problem? Visit this link for more details #menu { position: absolute; background: red; wid ...

What makes the nav class different from the navbar class in Bootstrap?

Recently, I delved into learning about bootstrap and web development. To my surprise, I stumbled upon the nav and navbar classes in bootstrap 4. I'm curious to know what sets them apart from each other and when it's best to use one over the other ...

Looking for solutions to manage mouseenter, mouseleave events and ensuring content dropdowns stay visible in Vue.js 2?

Hey there, I'm trying to figure out how to keep dropdown content from disappearing when using @mouseenter and @mouseleave. Here's what I have so far: <div class="wrapper"> <div class="link" @mouseenter="show = ...

Toggle the visibility of an element with a single button click

Below is a snippet of my sample code: SAMPLE HTML CODE: <ul> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <l ...

Utilizing mathematical operations within asp.net repeater control for precise calculations

I attempted to calculate the multiplication of two numbers using DataBinder.eval on an ASP front-end page, but it seems to only return 0. The database contains the following values; PPI = 0.45 MDPI = 0.5 However, when I perform the calculation, it alway ...

Is it possible to choose several columns in an AnonymousType query and store them in

Apologies if this question has been asked before, but I can't seem to find the right words to search for the solution. I have a code snippet that involves the ToArray method, which is where I'm encountering an issue... Here's the code snipp ...

Adjust the container within the column to match the height of the column in the bootstrap grid

Why is the green container expanding over the blue column when I apply height: 100% or h-100? Is there a way to make it fit just the remaining height of the column? <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstra ...

Easily transfer files without the need for a complete page refresh

The Strategy To ensure a seamless user experience, my goal is to upload files without triggering a full page refresh. All uploaded files will be temporarily stored, either in session or cookies, until the user successfully completes all form fields. File ...

Troubleshooting: Style sheets not loading on a page rendered by node

Today was my first attempt at learning Node.js and creating a basic server to display a single page with a header tag. However, I encountered an error stating that the CSS file could not be loaded. This is the code I used: const express = require('ex ...

Conceal list items by clicking elsewhere on the page

Currently, I am facing an issue with my search user functionality. Whenever a user clicks anywhere else on the page, the list of results does not disappear unless the user manually deletes all the words they have typed. This behavior is not ideal and despi ...

Can you explain the mechanics behind the animation of the upvote button on steemit.com?

Behold the upvote button of steemit.com: <span class="Icon chevron-up-circle" style="display: inline-block; width: 1.12rem; height: 1.12rem;"> <svg enable-background="new 0 0 33 33" version="1.1" viewBox="0 0 33 33" xml:space="preserve" xmlns=" ...

Recovering a web-based database using C#

Just throwing this out there. I've been working on a C# project that includes a feature to backup and restore an online MySQL database. The backup functionality is running smoothly, but I'm facing issues getting the restore function to work prop ...

What is the best way to rearrange three divs into two columns?

I am trying to rearrange the order of three divs in my markup layout. The desired layout is to display div one first, followed by three underneath it in the first column. Then, in the second column, I want to only show div two. My current CSS configuratio ...

What is the process for removing the highlighted border from a navigation menu in ASP.NET?

I am currently utilizing the navigation menu in the ASP.NET toolbox, but I am struggling to remove an unwanted golden border. Despite my efforts, I have not been able to find any information on how to resolve this issue. The golden border only appears when ...

Can a CSS gradient be layered on top of another element?

Curious about the technique that enables creating gradients OVER another div (a fading white horizontal line). Here is what I envision it to look like: Currently, this is what I have (I know, it needs work): The horizontal line is a basic with a color C ...

Is it possible to utilize formatted strings in Python selenium to locate elements based on different categories such as xpath, css, etc?

An interesting revelation just hit me and it's quite unsettling since my entire program relies on locating elements by CSS selector using formatted strings. Let's consider this example: stop_iteration_for_foh = driver.find_element_by_css_selecto ...

Issue with JavaScript Variable Not Reflecting Changes in Progress Bar

I'm in the midst of developing a game and have incorporated a progress bar to facilitate the incrementation of certain values on my HTML page. However, once the progress bar hits 100%, it updates the cost and level only once. After that initial update ...

Using Less in CSS values can sometimes involve incorporating slashes (`/`), such as in the shorthand for `font`

While working with Less and font shorthand, I came across an issue: .font(@weight: 300, @size: 22px, @height: 32px) { font: @weight @size/@height "Helvetica Neue", Arial, "Liberation Sans", FreeSans, sans-serif; } The above code snippet resulted in a ...