Placing a table inside a div container to ensure compatibility on all browsers

Although I typically avoid using tables, I am struggling to find a better solution for setting up a page layout with a search bar, three buttons, and two hyperlinks stacked on top of each other. The challenge is to have this control centered on the webpage.

The issue arises when trying to position the hyperlinks without using a table. Safari and Chrome do not render the layout correctly, unlike IE and Firefox which center everything as expected. In Safari and Chrome, the table containing the hyperlinks is pushed to the left side of the page.

I would appreciate any suggestions on how to achieve the desired layout or resolve the rendering problem in Safari/Chrome.

Code below

html

   
<div id="search" class="searchcontainer">
    <asp:TextBox ID="tbsearchterm" CssClass="watermark" runat="server" OnTextChanged="tbsearchterm_TextChanged" />
    <div class="buttons">
        <asp:LinkButton runat="server" Text="Search" class="button search-big" ID="btnSearch"
            OnClick="btnSearch_Click" />
        <asp:LinkButton runat="server" Text="Fx" class="button left big" ID="btnOperators" />
        <asp:LinkButton runat="server" Text="Save" class="button right big" ID="btnSave" />
    </div>
    <table id="searchoptions">
        <tr>
            <td>
                <a href="#" id="btnAdvanceSearch">Advanced Search</a>
            </td>
        </tr>
        <tr>
            <td>
                <a href="#" id="btnFilters">Filters</a>
            </td>
        </tr>
    </table>
</div>

CSS

    
.searchcontainer 
{
    min-width:840px;
    display:inline;
    position:relative;
    padding-top:20px;
    margin-left:auto;
    margin-right:auto;
}

#searchoptions
{
    display:inline; 
    text-align:left;
    font-size:.8em;
    width:100px;
    padding:0px;
    vertical-align:top;
    position:relative;
    margin:0px;
}


#tbsearchterm {
    width:470px;
    height:32px;
    text-align:left;   
    padding-left:10px;
    padding-right:10px;
    font-size: 1.3em;
    border:1px solid #cccccc;
    -khtml-border-radius: 2px;
    -ms-border-radius: 2px;
    -o-border-radius: 2px;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px;

}

Any tips or suggestions would be greatly appreciated!

Update This control utilizes jQuery to hide certain elements upon page load. As a result, using float is not practical. Even when some elements are hidden, the control still does not align properly but rather shifts to the left. Thus, I need to keep using display:inline for the nested elements within the main container ("searchcontainer").

Answer №1

body { width: 100%; text-align: center; }
.container { overflow: hidden; width: 500px; margin: 0 auto; }
input { float: left; }
button { float: left; }
.links { float: left; }

<div class="container">
   <input type="text"/>
   <button id="button1">Button 1</button>
   <button id="button2">Button 2</button>
   <button id="button3">Button 3</button>
   <div class="links">
        <a href="">Link 1</a><br/>
        <a href="">Link 2</a><br/>
   </div>
</div>

Float the input elements, buttons, and .link div to the left for cross-browser compatibility.

Feel free to test it out at this link: http://jsfiddle.net/F7hQf/

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

Determine whether the textfield is a number or not upon losing focus

I'm seeking advice on implementing a feature using jQuery and JavaScript. I want to create a text field that, when something is inputted, will automatically add .00 at the end if it's only a number. However, if someone inputs something like 2.00, ...

Using Cordova to create an accordion list on an HTML webpage

I am in need of an accordion list implementation for the given HTML code. I specifically want it to expand when 'Technical' is clicked, and collapse upon clicking again. Here is the HTML code: <!-- Techincal --> <div class= ...

Enable the set body to have certain sections that are scrollable by setting overflow=hidden

I am currently working on a website that features the following structure: <body> <section></section> <section></section> ... </body> To prevent scroll bars on the body, I have set the CSS property body{overflow:hidden ...

The search and sorting functionality in jquery DataTables is malfunctioning

I am facing difficulties with sorting and filtering the datatable as none of the JS functions seem to be working properly. I have already included the necessary JS files. Here are some details: I am connecting to a database to retrieve data in JSON format. ...

Enhancing the synchronization of data between the model and the view in

Can AngularJS support "double data-binding" functionality? I am trying to extract mat.Discipline[0].nom_FR from an array containing nom_FR, nom_DE, nom_EN, and nom_IT. The value of mat.Langue[0].langue is either "FR", "DE", "EN", or "IT" based on the sel ...

The dropdown submenu in IE10 disappears prematurely, making it difficult to hover over the submenu

One of my clients is experiencing an issue with the navigation menu drop-down on their site at . While it works fine on all browsers, there seems to be a problem with hovering over submenus in IE 10 - they disappear too quickly. The client is using the SR ...

Using Foreach with Bootstrap to display a grid of 6 column items with images

When using a foreach loop to display clients with images, the desired layout is for them to be listed in 6 columns. For instance, if there are 18 clients, they should be displayed in a grid of 6 columns and 3 rows. Here is the Razor code and HTML: <di ...

Managing images in JavaScript while conserving memory

Welcome I am embarking on a project to construct a webpage using HTML, CSS, JavaScript (jQuery), and nearly 1000 images. The length of the HTML page is substantial, around 5000px. My vision involves creating a captivating visual experience for users as t ...

What is the best way to incorporate an image sprite within table data?

Utilizing the Instant Sprite tool, I successfully created my own unique sprite image. With the help of a repeater control, I assigned the <td> class to be arg16 Private Sub cdcatalog_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handl ...

Tips for aligning audio and text files using JavaScript:

After displaying text below the video as subtitles, I'm now looking to synchronize the text with the video. Any ideas on how to highlight the text as the video plays? ...

Links in words not redirecting to asp.net documents

I have a collection of Word files that require hyperlinks. These hyperlinks lead to an htm file with an anchor, however the htm file is not accessible directly via a URL for security purposes. Instead, it links to an ashx handler file which fetches the f ...

What is the design for headers in accordion-groups with ngx-bootstrap?

Is there a way to customize the style of ngx-bootstrap accordion headers? I've attempted various methods, including copying and pasting code from the documentation for header customization. However, it hasn't been successful. When inspecting the ...

What is the reason behind the removal of the "disabled" attribute when setting the "disabled" property to false?

Initially, I have a disabled button: <button disabled="disabled">Lorem ipsum</button> When using button.getAttribute('disabled'), it returns "disabled". But once the button is enabled with JavaScript: button.disabled = false; The ...

What's the secret behind the functionality of this jQuery menu?

As I was browsing the website , I noticed that they have a menu in the top header with links like "Freebies" and "Inspiration". I searched for where the code for this menu is located, but couldn't find it. Can anyone help me locate the code? I' ...

An issue occurred during the building of the module (from ./node_modules/sass-loader/dist/cjs.js) and resulted in

Within the app directory, I've created a new folder called styles > custom > loader.scss. In the styles.scss file, I included the following import: @import "styles/custom/loader.scss"; However, upon doing so, an error message appeared ...

Do mouse users prefer larger buttons on RWD sites for a better experience?

Not entirely certain if this platform is the most suitable for posing this query, so if warranted, please close it and recommend a more appropriate venue for such inquiries. In the realm of responsive web design (RWD) today, it is common practice for webs ...

retrieve user input from various angular 6 components

Currently, I am in the process of developing a small web-based game using Angular 6. Within this project, I have two key components - play.component and setup.component. The main concept is to allow users to customize elements such as difficulty within the ...

Issues with jQuery functionality occurring when trying to display or hide div contents on dynamically loaded AJAX content

I have encountered an issue while working on a project that involves showing or hiding a div based on the selection of a drop down value. The show/hide functionality works perfectly when implemented on the same page, but it fails when I try to do the same ...

The make-xx-column() mixins in Bootstrap are malfunctioning

After careful examination, it looks like some of the Bootstrap mixins are not functioning as expected. Specifically, the .make-md-column() and .make-sm-column() seem to have no effect at all. Initially, I suspected that WebEssentials was not compiling the ...

What is the best method for disabling autoscroll for a specific div id when the :target attribute

I created this accordion menu using only html and css, but the buttons are built with the :target id. Is there a way to prevent the automatic scrolling when any button is clicked without using javascript? It currently moves to the anchor #id. I've se ...