Is there a way to position the button and text side by side in a straight line

I am looking to have the button and text aligned on the same line.

<div class="offers">
    <div class="container" style="line-height: 300px; text-align: center;">
        <h1>Enjoy our offers with your family <button class="offers-button"><a href="#">See all the benefits of therapies</a></button>
    </div>
</div>
button {
    background: transparent;
    color: #666;
    border: 1px solid #d4d4d4;
    padding: 10px 20px;
    margin: 0 10px 0 10px;
    transition: border .3s ease-in;
}
button:hover {
    border: 1px solid #909090;
    padding: 10px 20px 10px 20px;
}
button a {
    font-family: 'Raleway', sans-serif;
    color: #666;
    font-size: 14px;
}
.offers-button a {
    font-family: 'Raleway', sans-serif;
    color: #fff;
}
.offers-button:hover {
    border: 1px solid #fff;
}
.offers {
    width: 100%;
    display: table;
    height: 300px;
    background:url(../img/back.jpg) center no-repeat;
}

Answer №1

To align both elements vertically, you can utilize the vertical-align CSS property in this way:

box {
    line-height: 200px;
    text-align: center;    
}
box > h2,
box > h2 a {
    vertical-align: middle;
}

Answer №2

Check out the DEMO here

HTML I made some adjustments to the code by removing the h1 tags, as they were not ending properly and were not even found in the CSS styles.

NOTE: I set the font-size to 32px because the h1 tag is typically 32px in size

<div class="oferts">
    <div class="container">  
        Enjoy our special offers with your family
        <button class="oferts-button">
            <a href="#">See all the benefits of our therapies</a>
        </button>
    </div>
</div>

CSS Make sure to add this class to your CSS file for proper styling

.container
{
    line-height: 300px;
    text-align: center;
    font-weight:bold;
    font-size:32px;
}

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

Incorporating JSON data into an HTML table

Looking to populate an HTML table with JSON data, but struggling with parsing and appending the data correctly. Can anyone provide guidance or assistance? <!DOCTYPE html> <html> <head> <title>JSON Demo</title> < ...

What is the best approach to ensure the navbar is responsive based on the viewport size?

I am working on creating a responsive webpage that will show different navigation based on the viewport size. Currently, I have written this JavaScript code: var shownav = document.getElementById('show-nav'); if (screen.width < "720"){ ...

Displaying a profile hover card allows users to easily discover and choose whether to follow or explore

I created a profile hover card on my website with a follow/unfollow button. However, I encountered an issue - the hover card disappears when I move away from my profile thumbnail. How can I fix this so that the hover card stays visible on mouseover and dis ...

Discovering all invalid elements in an Angular 8 Form using Typescript by revealing required fields post button click

Once the button is clicked, I want to retrieve all invalid elements in the Form and showcase those fields that are either incomplete or required. ...

Gradually reveal each individual path of the SVG, one by one

I am faced with an SVG containing numerous paths like the following: <svg version="1.1" id="svg2" inkscape:version="0.91 r13725" sodipodi:docname="drawing.svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://w ...

What could be causing this excessive lag?

I've been developing a new website, but the "buttons" I'm using seem to be causing significant lag. I need help resolving this issue. You can view the website here: The problematic code snippet is shown below: <td> <a href="templi ...

The conflict between Material UI's CSSBaseline and react-mentions is causing issues

Wondering why the CSSBaseline of Material UI is causing issues with the background color alignment of React-mentions and seeking a solution (https://www.npmjs.com/package/react-mentions) Check out this setup: https://codesandbox.io/s/frosty-wildflower-21w ...

"HTML Form Input Configuration Bug: Multiple Selection Fails to Return

I am currently working on a web application using express, and I am trying to create a form for adding a new product. Within this form, I have implemented a multi-select feature for choosing the categories associated with the product. Below is the code sni ...

What is the recommended sequence for adding AngularJS to the index page?

I am new to AngularJS and currently working on a project where I need to include multiple JavaScript files in my index.html page. After doing some research, I came across a post on Stack Overflow that mentioned the importance of including the angular.js fi ...

How to create space between elements in CSS without using margin or padding?

Recently, I stumbled upon a fascinating website while working on my own CSS grid project: I am curious to know how it was achieved. The Portfolio elements on the website have space between them without any visible margins or paddings that I could identify ...

The issue of unordered list page-break-inside:avoid not being effective and causing an overlap with the footer

I have designed a webpage with a header, footer, and main content that includes Bootstrap 4 card list groups. My goal is to create a printable version of this list where the elements do not break between pages. However, using page-break-inside: avoid does ...

What is the best way to populate an object with an array's elements using JSON?

I previously inquired about a similar question, but with some variations. You can view it here. Since then, I have altered my approach to tackling the issue. You can find my JSON file here. This is the progress I've made with my javascript: $(docu ...

Verify role declarations and display components if valid

I am currently developing an application using Angular on the front-end and ASP.NET on the back-end. Within this application, there are two roles: user and admin. I have implemented a navigation bar with several buttons that I need to hide based on the use ...

Error encountered while building Dart WebUI

I am encountering issues when attempting to integrate web_ui into my existing Dart application. I have not yet incorporated any of the webui-specific code into my HTML file, I am simply trying to build. I updated the pubspec.yaml file with the web_ui pac ...

`Is there a way to hide inline text on small screens using Boostrap 4?`

Within this specific scenario, my goal is to conceal the text when viewed on smaller screens and solely display the icon located to the left (an icon representing comments from font awesome): <a id="newCommentLink" href="#"> & ...

The <form> element is giving me headaches in my JavaScript code

Trying to troubleshoot why my HTML pages render twice when I add a form with JavaScript. It seems like the page displays once with the script and again without it. Below is the basic HTML code: <form action="test.php" method="post"> <div class=" ...

What is the method to retrieve text from a div element with Webdriver-IO?

Is there a way to extract the value from the following HTML element using Webdriver-IO for automated testing? <div class="metric-value ng-binding" ng-style="{'font-size': vis.params.fontSize+'pt'}" style="font-size: 60 ...

Data not being displayed in dynamic <table>

Need help creating a dynamic table that displays data inserted in a specific format. {headers: ["header1", "header2"], rows: [["data1", "data2"], ["moredata", "wowoso muchdata"]]} The 'rows' consists of arrays where each array represents a row ...

Using jQuery or JavaScript to hide a div if the image inside it is unable to load

There is a div called 'userFeatureProductImage' that is duplicated. Sometimes a broken image may appear, so I would like to hide the div as a precautionary measure. How can I achieve this? ...

Is Ionic capable of storing data similar to sharedpreferences?

Hey there, I'm just starting out with the ionic framework and could use some advice. What is the best way to store user data like usernames, passwords, or login keys? Would it be beneficial for me to utilize HTML5 local storage? I want users to be ab ...