How do you center controls within a repeater control's item template?

I have a repeating control on my page that displays an image and a hyperlink one below the other. When I add more than one line of text, it causes the image to move up. I want the top of the images to be aligned horizontally and the text to flow downward if there is more than one line. Please provide some guidance.

Below is the ASCX code snippet I am currently using:

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> 
<asp:View ID="View1" runat="server"> 

<asp:UpdatePanel ID="UpdatePanelAnnouncements" runat="server"  UpdateMode="Conditional">
<ContentTemplate>

<table>
<tr>
    <asp:Repeater ID="repAnnouncements" runat="server">
        <ItemTemplate>
            <td style="padding-right:19px; padding-top:1px; padding-left:7px;">
                <asp:HiddenField ID="ItemID" Value='<%#Eval("ID") %>' runat="server" />
                <asp:HyperLink ID="hypImageEditLink" runat="server">

                <div class="ImageStyle" >
                <asp:Image ID="imgLink" Height="110px" Width="150px" runat="server" ImageUrl='<%#Eval("Images")%>' CssClass ="magnify"/>
                </div>

                </asp:HyperLink>
                <br/><br/>
                <div id="div3" class="Div3"><asp:HyperLink ID="hypTextEditLink" runat="server" Text='<%#Eval("Title")%>' CssClass="TitleStyle"/></div>
            </td>
        </ItemTemplate>
    </asp:Repeater>
 </tr>
</table>

</ContentTemplate>
</asp:UpdatePanel>
</asp:View>

Additionally, here is the CSS snippet for styling:

.div3
{
  width: 150px !important; 
  display:inline !important;  
  float:left !important;
}

 .ImageStyle
 {
   margin-left:8px;
   border-collapse: separate !important;
   box-shadow: 0px 0.5px 11px 4px #888888;
 }

  .ImageStyle:hover
    {
      opacity:0.5 !important;
      filter: alpha(opacity=50) !important;
      border-color:blue !important;
      border-width:thick !important;
     }

Answer №1

From what I gather from your inquiry, the issue arises when there is an abundance of text below a picture, causing other pictures to align themselves vertically in the middle of their cells. To rectify this situation, adjust your TD tag as follows:

<td style="vertical-align: top; padding-right:19px; padding-top:1px; padding-left:7px;">

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

Guide on aligning a popup next to the button that activated it using CSS and JavaScript

I am currently generating a dynamic quantity of divs, each containing a button that triggers a popup when clicked. I am attempting to position the popup below the specific button that activated it, but it remains static and does not move accordingly. <d ...

What could be causing the background color opacity of the HTML hr tag to decrease?

I am trying to modify the height and background color of the <hr> HTML tag. However, even though the height and color are changing, it appears that the background color opacity is decreasing slightly. What could be causing this issue? Here is my cod ...

Ensure the column breaks before the element without disrupting the wrapper in CSS

My objective is to always initiate a line break before a specific element, in this case, the h2 tag: https://i.sstatic.net/fy80H.png https://jsfiddle.net/hv0sm40o/3/ html <div class="columns"> <h2>Jelly pastry chocolate cake pastry</h2&g ...

The use of CSS float creates spaces between elements

Is there a way to stack the green DIVs on top of each other without any space between them in the given simple HTML code? I'm puzzled by the gap between the third and fourth green DIVs. * { margin: 0; } .left { width: 20%; background-color: # ...

Adjust font size using jQuery and CSS styles

I'm currently working on a website where the body has a specified font-size property that is inherited by all elements on the page. Some tags on the page have font-sizes specified in percentages (%). Others are assigned sizes in pixels (px). I&apos ...

What could be causing issues with my CSS/HTML on Internet Explorer, including version 9?

Utilizing modernizer and html5boilerplate's CSS, I have encountered challenges in designing and debugging for Internet Explorer. It seems that my reliance on FireBug has hindered my progress. Can someone please review my work-in-progress at and provi ...

Tips for creating a 3D illusion by coding a div or object to rotate around another object or div

I have reached a technical and intellectual roadblock. The issue at hand is this: I need the text to encircle an image and create the illusion that it is moving in front of or behind the image, while keeping the image static. Currently, 1) the rotating te ...

CSS flexbox completely collapses all child elements that are empty

Is there a way to collapse the empty "col" divs in this html structure while keeping the content divs equally sized (two columns in this case)? * { box-sizing: border-box; } .container { border: 1px dashed rgba(255, 0, 0, .5); background-color: b ...

Wavy CSS Animation

For assistance with my spinning image, please check out this fiddle: https://jsfiddle.net/dricardo1/9a8p6srb/ Hello! I'm struggling with a spinning image that has a noticeable wobble when rotating. I can't seem to find a solution to make the rot ...

Choosing an Option from Drop-down Menu in Materialize CSS with Selenium in C#

I am attempting to choose an item from a dropdown field on a page that is styled using Materialize CSS. I am currently working with Selenium webdriver in C#. Here is my most recent attempt: IWebElement tipoLoja = driver.FindElement(By.XPath("//select[@id ...

Unable to alter the background color of the text box

I am currently struggling with my code where I am trying to overlay a text box on an image. Even after setting the background color to white, it still shows up as transparent. I have successfully done this in the past, but for some reason, it is not work ...

Revamping Slideshows: Bringing CSS Animation to JavaScript

/* JavaScript */ var slides=0; var array=new Array('background.jpg','banner.jpg','image.jpg'); var length=array.length-1; $(document).ready( function(){ setInterval(function(){ slides++; ...

The positioning problem arising from using a Vuetify select dropdown within a datatable

Vuetify datatable is being used with 20 columns, functioning properly. To view all the columns, horizontal scrolling is available. Filters are needed for each column in the header, achieved using v-slot:header. An issue arises when clicking on the select ...

Issues with HTML rendering text

Having trouble with text display on my website. It seems to vary based on screen resolution, but I can't figure out why. Any insights on what might be causing this issue? Check out the source code here <body> <div id="navwrap"> < ...

adjust the webpage to be optimized for the size of the screen

Looking to adjust the webpage layout so that it fits perfectly on the screen without the need for vertical or horizontal scrolling. Additionally, we want the image to be centered. See below for the current code snippet: #copyright { top: 0px; right: ...

How can I access multiple icons using jQuery?

Below is the JavaScript code I am using: $(document).ready(function() { $.getJSON("Stations.php", function(jsonData){ $.each(jsonData, function(key,value) { $('#selectStation') .append($("<option></option>") ...

Having difficulty incorporating a video into the background

After searching online and attempting two different methods, I am still unable to achieve the desired result. I want a video to cover the entire background of my webpage. Here is what I have tried: CSS - video#bgvid { position: fixed; top: 50%; ...

What are some ways to change the appearance of a component using its parent?

In order to make changes to the CSS properties of a Vue component from its parent, effectively overriding any existing styles within the component, I am seeking a solution. Initially, I assumed that styling a component like <my-component> directly f ...

What is the best way to insert a tagline above a form?

I'm struggling to figure out where to place a tagline above my form. I want it to be neat and clean, but haven't been successful in finding the right spot. I attempted to insert an <h2> inside the form, but it doesn't look good at al ...

The SuiteTalk 2014.1 version of NetSuite Web Services seems to be returning inaccurate data when using the customerSearchAdvanced function for the parent

As I work on completing a NetSuite Web Services, SuiteTalk (2014.1), call using the customerSearchAdvance option to retrieve a customer efficiently, I have encountered an issue. The parentRef of the returned customer is showing different data compared to a ...