Difficulties arise when trying to align text vertically between two floating images

After running the code, I noticed that the text "Text Here" is positioned at the bottom of the div instead of the top. I have attempted to adjust it using properties like vertical-align, padding, and margin-top within the .subText styling, but so far, I haven't been able to resolve the issue.

Here is the HTML and CSS code snippet:

#footballLeft {
  float: left;
  vertical-align: middle;
}
#footballRight {
  float: right;
  vertical-align: middle;
}
.subText {
  text-align: center;
}
<div class="sect sectTwo"></div>
<div id="footballSection" class="subSection">
  <h1 class="titles">FOOTBALL</h1>
  <div class="subSubSection">
    <img src="img/teamhuddle.jpg" height="30%" width="30%" alt="Team Huddle" id="footballLeft" />
    <img src="img/womens1.jpg" alt="Womens First Team" height="30%" width="30%" id="footballRight" />
    <p class="subText">Text Here</p>
  </div>
</div>

Answer №1

I tested your code and it seems to be working fine for me. If you are still experiencing issues, I recommend trying to refresh your browser or adding the following code snippet:

.subText {
    position:relative;
    left: 220px;
}

This should have the same effect as centering the element.

Answer №2

Your content is already visible at the top for me. Note: Floated elements don't get affected by vertical-align

Can we use display:inline-block instead of floats? https://jsfiddle.net/xw9fce28/

Html:

<div class="sect sectTwo"></div>
    <div id="footballSection" class="subSection">
    <h1 class="titles">FOOTBALL</h1>
    <div class="subSubSection">
    <img src="http://image.flaticon.com/teams/1-freepik.jpg" height="30%" width="30%" alt="Team Huddle" class="football" />  
    <p class="subText">Insert Text Here</p> 
    <img src="http://image.flaticon.com/teams/1-freepik.jpg" alt="Womens First Team" height="30%" width="30%" class="football" />
    </div>
</div>

CSS:

.football {
   display:inline-block;
   vertical-align: top;
}
.subText {
    display:inline-block;
}

Answer №3

The code was functioning properly, however I realized that there was a part in my CSS file that I had commented out while testing and accidentally omitted the closing bracket within the comment.

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

How to implement multiple conditions with ng-if in HTML

I need to implement a button that is visible only for specific index numbers: <tbody data-ng-repeat="(wholesalerIndex, wholesaler) in wholesalers"> <tr> <td> <but ...

IE/Firefox returning empty value for Ajax requests

After spending two days trying to solve the issue, I still can't figure out why this code is failing in IE (v11) and Firefox while working fine in Chrome. I have read many questions on similar topics involving caching problems with multiple Ajax call ...

Fade out a component in Material UI/React by setting a timeout in the parent's useEffect hook for when it unmounts

Incorporating a fade out transition into my child component, <Welcome />, using Material UI's Fade component is my current goal. This transition should be triggered by two specific conditions: The timeout set in the useEffect function expires. ...

Can you provide step-by-step instructions on how to customize styles with MUI in my application?

I am encountering issues with MUI while attempting to customize the color of my buttons. The two methods I have tried so far have been unsuccessful. For example, Method 1: import React from 'react' import { Typography } from '@mui/material& ...

the sizing issue with three div elements

I am attempting to create 3 parallel divs in HTML. The middle div should be exactly 960px wide and centered on the page, with the left and right divs positioned on either side. The minimum width of the page is set to 1024px. When the browser width exceed ...

How can I use jQuery to automatically redirect to a different HTML page after updating a dynamic label?

When I click on a button in first.html, a function is called to update labels in second.html. However, despite being able to see second.html, I am unable to see the updated values in the labels. Can someone please advise me on how to achieve this? functi ...

Eclipse now features automatic CSS class suggestions to help streamline your coding

After using NetBeans for a while, I am now considering making the switch to Eclipse. Everything seems fine, but one thing that is bothering me is that Eclipse does not provide CSS class proposals like NetBeans does. In NetBeans, whenever I use or create a ...

The variable in my scope is not reflecting the changes in the HTML view

Here is my code for handling file attachments in AngularJS: $scope.attachments = []; $scope.uploadFile = function(files){ for(var i=0; i<files.length; i++){ $scope.attachments.push(files[i]); console.log($scope.attachments.length); } } ...

Switch the selected option in JQuery UI dropdown using a clickable button

I have a code snippet that is almost working. My goal is to change the selection of a JQuery dropdown select combobox using a separate button named "next". What I want is for the JQuery dropdown to automatically switch to the next selection every time I c ...

The Gulp task is not being recognized when I open the project in Visual Studio Code

Whenever I open gulp, I encounter an error related to minifying css and js files using gulp tasks. Despite my efforts to find a solution, the problem remains unresolved. Error Message: assert.js:374 throw err; ^ AssertionError [ERR_ASSERTION]: Task fu ...

Experiencing inconsistencies with CSS on certain devices?

When faced with a research issue, I usually turn to Google for answers. However, this time, I was unsure of where to begin. As part of my efforts to enhance my frontend development skills, I undertook The Odin Project and worked on a calculator project. U ...

core.js:15723 ERROR TypeError: Unable to access the 'OBJECT' property because it is undefined

Whenever I attempt to run this function, I encounter an issue. My goal is to retrieve the latitude and longitude of an address from Google's API. This error message pops up: core.js:15723 ERROR TypeError: Cannot read property 'geometry' of ...

Encountering a HttpMediaTypeNotAcceptableException while making a jQuery ajax request after upgrading to Spring 3.2.4版本

Whenever I attempt to execute a jQuery ajax call, I am facing the HttpMediaTypeNotAcceptableException. The current configuration that I have includes: Within the context (which is in the classpath), I have the following: <context:component-scan base- ...

How do I simulate a checkbox click with jQuery based on the text included in its ID?

Below is a sample table with checkboxes: <table> <tr> <td><input id="aaa_1" type="checkbox" /></td> <td>1</td> </tr> <tr> <td><input id="aaa_2" type="checkbox" /></td> ...

Prevent the function from being triggered repeatedly while scrolling

When a user scrolls to the bottom of the page, the following code is meant to load the next page. However, there are instances where it repeats itself due to rapid scrolling or while the AJAX content is still loading. Is there a way to prevent this code f ...

Facebook utilizes Ajax for refreshing the page and obtaining updates

How does the system for update notifications and chat work on Facebook? Ajax is used to send requests to the server, such as inserting records into a database. But how are these records pushed by the server to other users? Does the Facebook page constant ...

AngularJS - Changing Views with Templates

At the moment, I am changing my directives in the following manner. Within my directive: (function(){ 'use strict'; var controller = ['$scope', function ($scope) { }]; angular .module('moduleName' ...

Issue in Ionic 3 where ion-list does not scroll vertically on iOS devices when ion-items are dynamically generated using ngFor within the ion-list

When using Ionic v3 to develop a hybrid app, I encountered an issue where ion-items within an ion-list generated using *ngFor are not scrollable on iOS devices. Strangely, this problem does not occur on Android devices. Here is the HTML code snippet: < ...

In IE8/IE9, Div does not surpass PDF but functions correctly on FF and Chrome

Is it possible to have a DIV displayed over a PDF document? This method seems to work with Firefox, but not with Internet Explorer 8 or 9. It's worth noting that the problem persists regardless of which PDF file is being pointed to. <html> < ...

State of the Browser - JavaScript/jQuery

Looking for a method to identify when my browser is loading and display a loading icon. Is this approach appropriate, or should I follow a more common practice to achieve the same goal? Edit: This feature will be implemented on one of my websites during ...