Customize the appearance of buttons and tabs located in the header section

Front end development is new to me and I'm trying to learn, but I've hit a roadblock. I have 4 components - 2 buttons and 2 tabs that I want to style in a header at the top of the page. Specifically, I want one button on the top left with padding, another button on the top right with padding, and the tabs centered in the middle. I am utilizing jquery, jquery mobile, and angularjs. After researching their APIs, I couldn't find a straightforward solution, so it seems like custom CSS is needed. Currently, my components look like this:

<button>Button 1</button>
<div data-role="tabs" id="tabs"> 
    <div data-role="navbar">
        <ul>
            <li ng-class="{active: navigation.isSelected(1)}" > 
                <button ng-click="navigation.selectTab(1)">Tab 1</button> 
            </li>
            <li ng-class="{active: navigation.isSelected(2)}"> 
                <button class="ui-btn-active" ng-click="navigation.selectTab(2)">Tab 2</button> 
            </li>
         </ul>
    </div>
</div>
<button>Button 2</button>

I attempted wrapping everything in another div and setting floats, but encountered issues. When I tried to float the second button to the right, it moved to a new line, and there isn't a center float option. As a novice in this field, any guidance would be greatly appreciated!

Answer №1

  • To create the desired layout, enclose the elements within a div and set its positioning to relative
  • Assign classes or IDs to the tab div and buttons, then use these to position them absolutely
  • Adjust the top, left, and right properties of the elements as necessary
  • Ensure each element has a width specified in percentages to prevent overlap

You may need to tweak the values based on your requirements, but the example below should serve as a guide:

Check out this working jsFiddle

CSS

.myHeader{
    position: relative;
    height:62px;
}
.left-btn{
    width:10% !important; 
    position: absolute;
    left: 1%;
}
.right-btn{
    width:10% !important;
    position: absolute;
    right: 1%;
}
#tabs{
    width:75%;
    position: absolute;
    top: 10px;
    left: 12%;
}

HTML

<div class="myHeader">
<button class="left-btn">Button 1</button>
<div data-role="tabs" id="tabs"> 
    <div data-role="navbar">
        <ul>
            <li ng-class="{active: navigation.isSelected(1)}" > 
                <button ng-click="navigation.selectTab(1)">Tab 1</button> 
            </li>
            <li ng-class="{active: navigation.isSelected(2)}"> 
                <button class="ui-btn-active" ng-click="navigation.selectTab(2)">Tab 2</button> 
            </li>
         </ul>
    </div>
</div>
<button class="right-btn">Button 2</button>
</div>

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

Generate options for a dropdown menu based on the choice made in another dropdown menu utilizing ajax technology

Greetings, I am currently working on a JSP page that features a form with two drop-down lists. The first drop-down is designed to display the country names. While the second drop-down should show the states corresponding to the selected country. I have ...

The event for 'deviceready' in Cordova is not getting triggered when placed inside the angular .run block

Recently, I've been facing difficulties in getting 'deviceready' to register within AngularJS. It was functioning properly earlier, so I'm puzzled about what might have altered. If I trigger 'deviceready' from a global addEve ...

Develop an onclick function with an href attribute

I am interested in transforming links into AJAX versions whenever possible. To achieve this, I plan to implement a function called replaceLinks that will add an onClick handler to each link on the page and trigger ajaxPageWSM(href). This is what I currentl ...

Open the HTML page from a separate directory

I'm facing an issue with loading additional HTML onto a page in my project when a link is clicked. The HTML fragment file I want to load is stored in a different folder within the project structure. Despite my efforts, I keep encountering a 404 error ...

"Enhance Your Website with jQuery Checkbox Multi-Select and Row Selection

Take a look at the code and screen below. It's a configuration screen. When the Fieldname checkbox is clicked, all checkboxes will be selected. If a check is removed, all checkboxes will be deselected. Clicking the Field1 checkbox will select child ...

Processing made easy with jQuery

In my HTML page, I have multiple rows that represent records from a database. Each row contains input fields and a link at the end. When I click on the link, I need to capture the values of the input fields within the same row. Here is an example of the H ...

Why does AngularJS treat $http response.data as an object, even though PHP sends back a JSON string?

I am struggling with an AJAX call to PHP. The Angular code seems simple: $http( { // ... } ) .then( function cf_handle_success( response ) { console.log( response.data ) ; // --> [object Object] } , ...

What could be the reason for my button to update only at the completion of the "each" loop?

Is there a way to update the button text before the loop, so that users can receive feedback while it's running? Currently, the text only updates after the loop has completed. In my scenario, the button displays "Updating please wait..." after the lo ...

Form submission requires a checkbox to be checked

I have been searching for a way to make checkboxes required. Is there a method similar to using required="required"? Currently, I generate my checkboxes in the following manner and would really appreciate any guidance on this topic. It's crucial for m ...

What is the method to switch between radio buttons on a webpage?

Here is an example of HTML code: <input type="radio" name="rad" id="Radio0" checked="checked" /> <input type="radio" name="rad" id="Radio1" /> <input type="radio" name="rad" id="Radio2" /> <input type="radio" name="rad" id="Radio4" /& ...

Aligning UL LI elements vertically for multi-line textORHow to vertically

I am dealing with a ul list that contains both single and multi-line li text. The issue is that the second line of the multi-line text starts at a different indentation than the first line. I need a simple solution to resolve this problem that works seaml ...

Creating an overlay button within various containing divs requires setting the position of the button

Tips for overlaying a button on each HTML element with the class WSEDIT. My approach involves using a JavaScript loop to identify elements with the CSS class WSEDIT, dynamically create a button within them, and prepend this button to each element. Below ...

The perplexing problem of scrolling in Dojox/mobile/scrollableview

I've noticed some scroll issues with the dojox/mobile/ScrollableView (version 1.10+) in my cordova application, specifically on Android phones. This problem seems to be affecting other widget-based architectures and even some store apps as well. I wou ...

The jQuery Ajax function seems to be malfunctioning, while the PHP code is executing smoothly without any

I attempted to utilize AJAX to send form data to a .TXT file using PHP code. The information is successfully being added to the text file, however, the AJAX functionality is not functioning properly. Can someone please point out the error in my code? ...

Is there a way to remove the bold styling from text next to JavaScript?

I recently launched a website at www.mvscaccounting.com, and I added a search engine made from javascript at the bottom of the page. Next to it, I wanted to put a "all rights reserved" notice. However, whenever I try to add any text next to the search engi ...

Limiting the displayed portion of a table and implementing scrolling instead

I am currently working with a static HTML template that contains the following code: <table> <thead></thead> <tbody></tbody> </table> Using jQuery and AJAX, I am dynamically adding and removing rows and columns ...

Covering the entire screen, the Div element takes up the entirety of

Just like with other pages, the main div always takes up the entire screen visible to the user. As they scroll down, another div becomes visible: example1 , example2 Regardless of the screen size, the main div will always fill the space visible to the use ...

Switching the theme color from drab grey to vibrant blue

How can I change the default placeholder color in md-input-container from grey to Material Blue? I have followed the instructions in the documentation and created my own theme, but none of the code snippets seems to work. What am I doing wrong? mainApp. ...

"Title, background hue 3, and color lined up in a single

.title { background-color: #FFC20E; font-size: 23px; font-weight: 600; padding: 5px 0px 5px 22px; font-family: "Open Sans"; } <h3 class="title">Title</h3> I need to create a title with a unique background color, can you ple ...

Executing a Restangular GET request with information included

Is there a way to make a GET request with data in Restangular? My AngularJS app uses Parse as the backend, and for logging in, it needs a GET request with data: curl -X GET \ -H "X-Parse-Application-Id: ..." \ -H "X-Parse-REST-API-Key: ..." ...