CSS - Struggling with Aligning Button Elements

I'm struggling to align buttons correctly on my webpage.

Here's what I have so far:

<div class="containerBoxes">                                        
   <div class="search">
       <form id="search-form" action="search.aspx" method="GET" accept-charset="utf-8" class="navbar-form" style="height:35px; width:100%" >
       <input type="text" name="s" onblur="if(this.value=='') this.value=''" onfocus="if(this.value =='' ) this.value=''"  />
       <a href="#" onclick="document.getElementById('search-form').submit()"></a>
       </form>
   </div>


   <form id="Form1" runat="server">
        <asp:ToolkitScriptManager ID="scrpMngMaster" runat="server">
        <Scripts>
          <asp:ScriptReference Path="~/js/jquery.js"/>
          <asp:ScriptReference Path="~/js/jquery.easing.1.3.js"/>
          <asp:ScriptReference Path="~/js/camera.js"/>
          <asp:ScriptReference Path="~/js/jquery.ui.totop.js"/>
          <asp:ScriptReference Path="~/search/search.js"/>                        
          <asp:ScriptReference Path="~/js/google.js"/>
          <asp:ScriptReference Path="~/js/livechat.js"/>  
          <asp:ScriptReference Path="~/js/bootstrap.js"/>  
        </Scripts>
        </asp:ToolkitScriptManager>    

  <div class="newsletter">                               
    <input type="text" runat="server" id="inputNewsletterEmail" onfocus="if(this.value =='Newsletter Sign Up - Enter Email' ) this.value=''" onblur="if(this.value=='') this.value='Newsletter Sign Up - Enter Email'" value="Newsletter Sign Up - Enter Email" style="background-color:#232323; width:95%;" />
    <asp:RegularExpressionValidator  
        ID="regEmail"
        ControlToValidate="inputNewsletterEmail"
        Text="(Invalid email)"
        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
        Runat="server" />
        <asp:Button id="btnNewsletter" runat="server" class="btn btn_" Text="subscribe" OnClick="btnNewsletter_OnClick" />
        <asp:Label ID="lblSuccess" runat="server" Visible="false" ForeColor="#97D816" Font-Bold="true" Font-Size="12px"></asp:Label>
   </div>


 </form>
</div>

CSS:

.containerBoxes
{
  float:right;
}

The problem I'm facing is that the 'submit button' still doesn't line up with the newsletter text field. Any assistance would be greatly appreciated!

Answer №1

It is advisable not to rely on tables for your layout. Tables should only be used when you actually need to display tabular data, which makes perfect sense, right? Instead, consider the following approach:

HTML

<div class="search">
    <input type="text" />
    <img src="glass.png" />
</div>

CSS

.search{
    position:relative;
}
input{
    padding-left:30px;
}
img{
    position:absolute;
    top:5px; /* adjust value as needed */
    left:300px; /* adjust value as needed */
    z-index:100;
}

Edit: The original question has been updated by the OP. However, I will keep this solution here for anyone seeking guidance on how to integrate a magnifying glass icon within a text field.

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

Creating a navigation bar that stays fixed at the top of

Hey there, currently I am utilizing a combination of jquery and css to affix my navigation menu at the top when scrolled. However, the problem is that my navigation menu is positioned beneath a div with a height set in viewport units (vh). The jquery scr ...

Utilizing CSS in Angular to Conceal Background Images in the Project

CSS and HTML. Encountering an issue with the structure of my Angular project in the home.component.html file: <div id="homecontent"> <div class="imageslide"> <ng-image-slider [images]="imageObject" [imageSize]="{width: &apo ...

The right alignment for ul and li styles is recommended for a cleaner appearance

Here is the fiddle provided below: http://jsfiddle.net/Fx9rA/ <div id="wrap"> <ul id="accordion"> <li> <h2 id="first">CMT</h2> <div class="content"> ...

What is the best way to expand ScrollToBottom to cover the entire screen height?

Check out this code sandbox that showcases a Logs React component functioning perfectly. The implementation incorporates react-scroll-to-bottom to display a page with a header and logs. What's interesting is that the log section dynamically adjusts i ...

Troubleshooting: Datepicker not appearing in Bootstrap

Here is the detailed markup for the datepicker component: <div class="form-group row"> <div class="col-xs-3 col-md-offset-9"> <label class="control-label">Pick Date</label> <div class="input-group date" id="dp3" data-d ...

The 1st DIV element nudges the content within the 2nd DIV Element, causing it to stretch beyond the screen with 100%

I have gone through several other questions, but I am struggling to integrate the solutions into my problem. My main content DIV is set to 100% height and works perfectly fine until I add another element outside of the DIV towards the top of the browser. ...

Utilizing Python to merge and lookup keys within a dictionary on a Flask template

I am making calls to two different API endpoints which are returning the following data: api1 = [ { "size": "SMUS", "price": "0.02" }, { "size": "LGUK", "price": "0.00 ...

Update the CSS appearance? (Redraw page)

I recently ran into a strange issue while working on an app using Cordova (Phonegap). The styling of many elements in the app depends on the class I set on the body element. For example: .gray .background{ background: gray; } .gray .title{ color: ...

What is the best way to reference the className within nested SCSS when working with Next.js and React.js?

I am working on customizing a navbar that includes a hamburger button. My goal is to change the style, specifically the bar color and the appearance of the hamburger button, upon tapping. I have already attempted using &:active and .activeBar in the SCSS f ...

If one check box is selected, the other check box will automatically vanish

In my code snippet below, I have set up a section that functions as intended. However, I am encountering an issue where the shopping cart box remains even after deselecting the first checkbox. My goal is to have the top box act as the main controller, so i ...

Eliminating render-blocking CSS in PageSpeed - one stylesheet at a time

Currently, I am testing the best optimization practices for front-end development. As part of this process, I have utilized gulp and npm to merge and minify my CSS and JS files into a single all.min.css and js.min.css file. Upon analyzing my website using ...

Trouble with centering navigation bar using HTML margin:auto

Below is the code snippet I'm currently working on: .nav-item { display: inline; color: white; padding: 30px 10px; font-style: bold; font-family: sans-serif; font-size: 20px; width: 1000px; margin: 0 auto; } .nav-container { back ...

Attempting to dynamically change the text of a button in JavaScript without any user interaction

I have created a button function that displays a word's definition when clicked. However, I am now attempting to modify it so that the definitions are shown automatically every few seconds using "SetInterval" without requiring a click. I am unsure of ...

What is the most effective method for arranging divs in a horizontal layout?

When it comes to creating a horizontal three-column div layout, there are a variety of methods to consider: Position: relative/absolute; Float: left/right; with margin: 0 auto; for center div Float: left; for all divs Display table / table-cell What do ...

Sideways and alternative directional scrolling

I need assistance achieving a horizontal scroll with the main content centered in a div, while having links that move left and right. <div id="left"> Scrolls left </div> <div id="home"> Opens on this </div> <div id="right"> ...

Certain CSS styles for components are missing from the current build

After building my Vue/Nuxt app, I noticed that certain component styles are not being applied. In the DEVELOPMENT environment, the styles appear as expected. However, once deployed, they seem to disappear. All other component styles render properly. Dev ...

The GLTFLoader encountered an issue with importing files outside of the module

Having some issues with the updated version of THREE.js, specifically when using the GLTFLoader. I keep encountering the error referenced above. Here is how I imported it in a separate js file: test.js import { GLTFLoader } from "three/examples/jsm/load ...

I am having trouble accessing the props testHighlight from the parent component when using the componentDidMount and componentWillReceiveProps methods

I'm brand new to working with react and I'm currently attempting to integrate react-highlight-words into my application for text searching purposes. I've set up a basic search textbox within the SearchBar.js file, while the highlighter compo ...

Challenges with Nginx URL redirection

When a page request is made, it goes through the "check.php" process: rewrite ^/(.*)$ http://localhost/check.php?page=$1 The "check.php" file carries out security checks before loading the requested page: <?php // ... security measures requi ...

The span exits the external div only once the animation has concluded

I utilized jQuery to create an animation effect: http://jsfiddle.net/rxCDU/ UPDATE: Please note that this effect is optimized for Chrome browsers! The animation works correctly, however, the green SPAN element moves out of the red DIV only after the ani ...