What is the best way to ensure that these social icons are perfectly centered on the page across all web browsers?

Visit my website here: foxweb.marist.edu/users/kf79g/contact.php

I'm stuck on the final step needed to deploy my website and finish it. The issue I'm facing is with the social icons when viewed on medium and small screens. I want them to be centered and fully responsive across all devices. I've tried creating a container to make them responsive, but they appear messy in IE 7-10. As the page width decreases, the icons start moving to the next line instead of staying aligned. I attempted adjusting margins, but it messed up the centering alignment for the entire page. I'm at a loss on how to fix this problem. Any help would be greatly appreciated.

View the visual representation of the issue in IE here.

Here's how I want it to look like in modern browsers: here.

HTML:

<h2> Social networks </h2><br/>

    <div id = "center_icons">
        <a href="https://www.facebook.com/lenny.pfautsch" target="_blank"><img src="images/facebook.png" alt="facebook" style="margin:1px;"></a> 
        <a href="https://plus.google.com/113122168458946246215/posts" target="_blank"><img src="images/google-plus.png" alt="google plus" style="margin:1px;"></a>
        <a href="http://www.linkedin.com/pub/leonard-pfautsch/53/b34/1a2" target="_blank"><img src="images/linkedin.png" alt="linkedin" style="margin:1px;"></a>
        <a href="https://github.com/LeonardPfautsch" target="_blank"><img src="images/github.png" alt="github" style="margin:1px;"></a>
    </div>
<br/>

</div>

</section>      

Main CSS:   

#details_section {
    max-width:100%;
    float:left;
    margin-right:20px;
}

Large screens:    

#details_section {
    width:320px;
}

Medium screens:    

#center{
width: 450px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

#center_icons{
width: 213px; /*this value is changing for IE and chrome*/
  display: block;
  margin-left: auto;
  margin-right: auto;
}



Small screens:    

#center{
width: 220px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width:100%;
}

#center_icons{
width: 214px; /*this value is changing for IE and chrome*/
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width:100%;
}

Answer №1

You may want to consider removing spaces between "=", and using double quotes instead of single quotes.

<div id="center">
<div id="details_section">

should look like this:

<div id="center">
<div id="details_section">

It's important to include the image size in your code as well.

<div id="container">
<div id="center_icons">
<a href="https://www.facebook.com/lenny.pfautsch" target="_blank"><img src="images/facebook.png" alt="facebook" width="40" height="40"></a>

<a href="https://plus.google.com/113122168458946246215/posts" target="_blank"><img src="images/google-plus.png" alt="google plus" width="40" height="40"></a>

<a href="http://www.linkedin.com/pub/leonard-pfautsch/53/b34/1a2" target="_blank"><img src="images/linkedin.png" alt="linkedin" width="40" height="40"></a>

<a href="https://github.com/LeonardPfautsch" target="_blank"><img src="images/github.png" alt="github" width="40" height="40"></a>
</div>
</div>

A simpler CSS approach would be:

div {border: 1px red solid;padding: 5px}   /*this is just for testing purposes*/

#container {
        text-align:center;
    }

    #center_icons{
    width: 214px; /*this value varies for IE and chrome*/
      display: block;
      margin-left: auto;
      margin-right: auto;
      max-width:100%;
    }

Test it out here: http://codepen.io/anon/pen/mAjzo

Answer №2

To center content, simply utilize the <center> </center> tags within your code instead of using a Div with the id "center".

Answer №3

To address this issue, adjust your CSS properties by carefully determining the screen coordinates and applying them to the margin. Alternatively, you may consider leveraging HTML5 for a possible solution.

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

showing database table contents on a website page

What is the best way to retrieve data from a MySQL database that corresponds to user input on a web page, and then showcase the content without having to reload the page using PHP or another suitable language? I would greatly appreciate any assistance wi ...

jQuery blocking the Ajax response in IE

Currently attempting to make an API call using the $.ajax() function. The response is successful in Firefox, but encountering a blockage in IE due to jQuery. The debugger shows the error message: Permission denied - jquery-1.4.2.min.js line 127 charac ...

Tips for incorporating captions into a slideshow

I've been experimenting with different methods to include captions in my slideshow, but haven't had much success. I simply want to add a div at the bottom of each image. Do I need to modify my script or should I consider adding something else? H ...

Allow iframe to be edited within jsfiddle

I have a question that I need to ask soon, but first I need an editable iframe in jsfiddle. It's working fine on my local machine, but not on jsfiddle. I believe it's because of the frames being used? On my local machine, I use: setTimeout(&apo ...

Is there a way for me to retrieve the icons through a content query?

Currently, I am working on customizing a background slider. However, in the CSS file: span.cbp-binext:before { content: "\e000";} The issue I am facing is that I am only getting squares as icons. Is there a way for me to replace these squares with a ...

Concealing the side navigation menu with HTML and CSS

Hey there, I'm trying to make my navbar automatically hide when the mouse is moved. I found an example that I want to use here. Despite reading some online documentation, I just can't seem to figure out how to do it. Here's a snippet of my c ...

Adjust the size of the sliding tool with images of varying dimensions

My mobile-first slider features three different types of images: tall, horizontally long, and square. I want the size of the slider to be determined by the horizontally long image and then scale and center the other images to fit its size. To achieve this, ...

What is the reason behind the success of this location?

Curious about the functionality of this particular JavaScript code with its corresponding HTML structure: function getCityChoice() { const location = document.querySelector("form").location.value; console.log(location) } <form name="reserve" a ...

Guidelines for utilizing the php mail() function

It seems that there is an issue with this code when running it on a local host versus a live server. I am attempting to use this code for a mail function, which works on another site but not on this one. I know the code will produce an error on localhost ...

Ways to reload an independent page in order to access PHP session variables:

Starting off, I want to mention that my approach may not be the most efficient. As a novice in JavaScript and PHP, I am aware that there are better and simpler ways to achieve what I'm attempting. The issue seems to be related to session variables an ...

Ensure that text within openhtmltopdf is aligned to the right and any unnecessary white space at the

Currently, I am using the open source project openhtmltopdf but I have encountered a certain issue. Within a div-element, I have a p-tag with text-align: right styling. The text is aligned correctly to the right until there is a line break due to the widt ...

CSS: Containers displayed side by side when screen width is above a certain threshold, otherwise stacked on top of each other

I am trying to make two containers responsive without using media queries or JavaScript. When the screen size is 500px or less, I want the containers to stack on top of each other and take up 100% of the screen width. But when the screen size exceeds 500 ...

Adding a class to unhovered elements with jQuery/JS: a step-by-step guide

I have a variety of elements that are almost working how I want them to. There are four divs in total. Depending on the URL visited, I want a specific div to be fully transparent/active. The next div in line should animate in and out of transparency simul ...

What is the significance of the "component" prop within MUI components?

I am a beginner in React and HTML. Currently, I am using MUI and React to create my own website. I am currently attempting to add an "Upload button" that will allow me to select an image file when clicked. Below is the official implementation: <Button ...

Leveraging the Bootstrap 3 audio player, although displaying a standard HTML5 output

When trying to use the Bootstrap 3 player to display an audio player, I'm encountering an issue where the page only shows a default black HTML5 audio player output. Here is my current directory structure: miuse/ application/ bootstrap/ ...

How can custom JavaScript objects have tags set upon click?

When it comes to JavaScript object referring, things can get a bit confusing. Imagine having a tag like this: <button id='myButton'>Hello</button> Now, let's say you create a custom class in JavaScript: function myClass(){ ...

What are the connections between osCommerce "box" files and CakePHP?

My previous experience involves working with the osCommerce shopping cart and I appreciate how they use "require" to easily add different boxes to the left or right side columns of the website. require(DIR_WS_BOXES . 'shopping_cart.php'); I am ...

The error alert must be displayed directly beneath the specific box

When error messages occur in this code, they are displayed through an alert box. However, I would prefer to have the error message appear below the specific text box instead. This means that when I click on the submit button and a field is left empty, the ...

The responsiveness of Material UI font sizes leaves much to be desired

After building my website with material UI components like autocomplete boxes, tabs, and buttons, I noticed that the components adjust responsively to changes in width, but the text remains static. For instance, the Autocomplete component resizes based on ...

The Send.php script is missing the input fields for Name and Email

Running my own website at CrystalVision.com, I have some challenges with my PHP skills. The issue lies within my send.php file. Although the email functionality works fine and I receive messages, the Name and Email fields filled in by users are not display ...