Steps for making a button with both an image and text:

I am in the process of designing a basketball-themed website and I am looking to incorporate custom icons/buttons that link to various pages on the site. My vision is to have a unique button that features a circular image with accompanying text below it.

However, I am unsure about how to achieve this seamless integration of both text and images within the same icon.

Your guidance on this matter would be greatly appreciated. For reference, here is an example of the kind of design I am aiming for: https://i.stack.imgur.com/5xgEo.png

Answer №1

To achieve this effect, utilize HTML and CSS coding techniques

<div class="wrapper">
<img src="example.jpg" alt="image missing">
<div class="middle">Centered</div>
</div>

<style>
.wrapper {
position: relative;
text-align: center;
color: white;
}

.middle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

Answer №2

Utilize anchor tag to create clickable links with images and text.

<a href ="link" >
   <div class="class_name" >
      <img src ="image_path" >
      <p> text </p>
   </div>
</a>

To make text a clickable link:

<a href ="link" > text </a>

By using the anchor tag <a>, anything placed between the opening and closing tags will become a clickable link that directs users to the specified URL in the href attribute upon clicking.

Answer №3

If you're looking for an alternative approach, consider the following:

* {
  boz-sizing: border-box;
}

h1 {
  font-family: serif;
  background: #444;
  padding: 25px;
}

.box {
  background: #eee;
  border-radius: 8px;
  display: block;
  padding: 15px;
  text-align: center;
  max-width: 200px;
  text-decoration: none;
}

.box figure {
  margin: 10px 0 20px;
}

.box figure img {
  border-radius: 50%;
}

.box .content {
  font-weight: normal;
  text-transform: lowercase;
  color: #2e4b9c;
  margin: 0 0 20px;
  font-size: 14px;
}
<a href="#" class="box">
  <figure><img src="http://via.placeholder.com/150x150"></figure>
  <div class="content">
    Enjoy the Outdoors
  </div>
</a>

Answer №4

Enhance your content by incorporating images or inserting hyperlinks. Take a look at this example:

<a href=“test.html”>
    <div>
        <img src=“img.jpg” alt=“test”/>
        <p>Link Test</p>
    </div>
</a>

Answer №5

To ensure your HTML is valid, it is important to carefully choose which elements you include. When using an anchor tag, only inline elements can be nested within it. However, CSS allows for flexibility in styling.

Example of HTML:

<a class="btn">
    <span class="btn-img"></span>
    <span class="btn-text">Get started with soccer</span>
</a>

CSS styles:

.btn {  
    display:block;
    padding:10px;
    background-color:white;
    border-radius:5px;
    position:relative;
    width:200px;
    text-align:center;
}
.btn-img {
    position:relative;
    width:175px;
    height:175px;
    border-radius:50%;
    display:block;
    margin:0 auto;
    background-color:red;
    background-image:url(YOUR IMAGE);
 }
 .btn-text {
   text-transform:uppercase;
   font-size:12px;
 }

Answer №6

Make sure to click on the following link:

https://jsfiddle.net/9wjcya06/

<a href ="#" class="btn-link" >
   <div class="button" >
      <img src ="https://i.pinimg.com/originals/40/97/c4/4097c40d4f2e1bbcc9044be03b5f730e.jpg" alt="img" >
      <span> BEGIN YOUR BASKETBALL JOURNEY </span>
   </div>
</a>

Answer №7

Check out the code below:

.img{
    border-radius: 50%;
    height: 120px;
    width: 120px;
    padding: 11px;
    padding-bottom:0px;
}
.txt{
   font-family: Georgia, serif;
    text-align: center;
    width: 85px;
    color: blue;
    padding-left: 34px;
    font-size: 14px;
}
.btn{
    background-color: white;

}
<button class="btn">
<img class="img" src="https://material.angular.io/assets/img/examples/shiba1.jpg"/>
<p class="txt">start playing basketball</p>
</button>

Answer №8

First, you'll want to include an icon library like font awesome.

Next, add the icons to your HTML buttons

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.btn {
background-color: DodgerBlue;
border: none;
color: white;
padding: 12px 16px;
font-size: 16px;
cursor: pointer;
}

/* Darker background on mouse-over */
.btn:hover {
background-color: RoyalBlue;
}
</style>
</head>
<body>
<p>Icon buttons with text:</p>
<button class="btn"><i class="fa fa-home"></i> Home</button>
<button class="btn"><i class="fa fa-bars"></i> Menu</button>
<button class="btn"><i class="fa fa-trash"></i> Trash</button>
<button class="btn"><i class="fa fa-close"></i> Close</button>
<button class="btn"><i class="fa fa-folder"></i> Folder</button>

</body>         
</html>

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

Ways to eliminate excess space at the top of a page while utilizing float elements

After doing some research online, I've come across advice on how to remove the space at the top of a web page which usually involves setting the margin and padding of the body element to 0: body { margin: 0; padding: 0; } You can find more i ...

The Parallax effect reference hook does not seem to be functioning properly with components in NextJs

I'm attempting to implement the useParallax hook on an element within my JavaScript file. My setup involves NextJs, ReactJs, and styled components. Here is how I integrated the hook: Mainland.js import React, { useEffect, useRef } from 'react&ap ...

Creating tilted divs with dynamic height to perfectly fit the content

I'm struggling to incorporate this design into my webpage; I can't seem to get the right div's height to match the left div as depicted in the second image. Can someone offer some assistance? Additionally, when viewed on mobile, the squares ...

Is it possible to modify the dropdown menu so that it opens on the right side instead of using a select tag?

Is there a way to make the drop-down from the select tag open to the right side(drop-right)? <label for="ExpLabel">Select Message Expiry:</label> <select name="ExpSelect" id="Expiry"> <option value="ExpiryDate">1 Day</opt ...

Is there a way to ensure that when displaying information boxes with Bootstrap, the inputs do not get misplaced or shuffled to the wrong location

I have been working on a form that needs to display an alert: When clicking the button next to the input control, an alert should appear. Although the alert is showing correctly, the input controls are shifting to the wrong position afterwards: The desir ...

Troubleshoot: Unable to trigger change event for input type file

Hey, I'm trying to capture and display the file name that a user selects using an input type file control. Unfortunately, the jQuery onchange event doesn't seem to be working in IE 8. Does anyone have a solution for this? // Here's my jQuer ...

Creating an interactive date selection feature with a calendar icon in MVC 5

I currently have a textbox that displays the datepicker when clicked. However, there is now a requirement to add a calendar icon inside the textbox. The datepicker should be displayed when either the calendar icon or the textbox is clicked. Below is the co ...

Leveraging HTML within jQuery UI autocomplete

In the past, I was able to include HTML in the JSON array I used for autocomplete with jQuery UI before version 1.8.4. For example: $row_array['label'] = '<span style="color: red; font-family: courier;">User, Name</span>'; ...

Get rid of the rollover effect on the <a> tag when hovering over an image

I have a snippet of code that is fully functional. <div class="user-pic round-pic"> <a href="<?php echo $userLoggedIn; ?>"><img src="<?php echo $user['profile_pic']; ?>"></a> </div> The issue lies in i ...

Best practices for embedding Internal CSS and rectifying missing classes in mobile view for email templates on Gmail

I am currently facing an issue with my email template. While it works perfectly fine in Outlook web and the Outlook app, Gmail web and Gmail's internal CSS strip away certain classes automatically. In an attempt to hide the pre-header on mobile devic ...

Submit data in the manner of a curl request

Instead of using a curl command to push a file to a web server, I am attempting to create a simple webpage where I can select the file and submit it. Here is the HTML and JavaScript code I have written for this purpose: <html> <body> <i ...

Utilize Multidimensional Arrays in HTML

I have a pair of fields called url and id. <input type='url' name='data[web][url]'><input type='number' name='data[web][id]'> <input type='url' name='data[web][url]'><input t ...

Suggestions for activating a particular accordion divider?

I've come across a seemingly simple question that has been causing me some trouble. I am attempting to expand, open, or collapse a specific accordion panel, but have not been able to find an answer so far. Let's say I have three panels identified ...

The blur filter in Safari causes colors to appear distorted

I am having an issue trying to add a blur filter to an SVG element. It appears that Safari is not rendering the colors correctly. Take a look at this example: <svg height="110" width="110"> <defs> <filter id="f1" x="0" y="0"&g ...

Tips for deleting part of the URL at the end of all hyperlinks on a webpage

I have a large number of links on the same page that I would like to clean up by removing everything from specific characters until the end of the URL. Currently, there are too many links like this scattered throughout my page. The string "$amp;rs" or "&a ...

Update the 'checked' attribute of a radio button when the form is submitted

How do I dynamically change the content of an HTML table based on which radio button a user selects using jQuery? For example, when the page loads, I want the United Kingdom radio button to be checked and the table content to display as 'blue'. I ...

How can I combine an onkeypress and onclick event listener in one method?

I have two inquiries, somewhat intertwined. 1) Is it feasible to merge the 2 functions below into a more efficient function, or do I need to create a function and then call it in both event listeners? input.addEventListener("keyup", () => { if (eve ...

Using SVG as a background image on Internet Explorer with zoom capabilities

I am having an issue with my SVG used as a background image: <div class="bubble"></div> Here is the CSS I am using: .bubble { background-image: url(https://beta.creasoft.cz/Images/bubble-small.svg); background-repeat: no-repeat; width ...

Is it possible to incorporate a foreach loop while also implementing unique adjustments at specific locations within the code?

I have been searching for a solution to this problem on various forums, but I couldn't find one that fits my needs. My challenge is to create a foreach loop for 12 elements, with 3 of them having a different class applied to them. This is the code I ...

Creative Vue.js and Tailwind CSS card layout featuring an image extending beyond the boundaries of the card

I'm attempting to design a card where an image pops out of the card. I've tried using z-index, but it doesn't seem to be working as expected. Here is the code I have: <div class="flex flex-col"> <div class=&quo ...