How can I add text to a bar or table using CSS/HTML?

I am trying to create a design similar to this:

http://img291.imageshack.us/img291/5571/bartablestyling.png

Currently, I only have the top bar in place.

When I attempt to add text, it ends up below the profile picture. I want to avoid using float:left for positioning.

Is there a way to use a table to achieve this text layout and properly adjust the spacing indicated by the red arrow that I added?

Here is the code snippet I am working with:

<div style="background-image: url(images/notificationShelfBg4.png);
    background-repeat: repeat-x;
    background-position: bottom; width: auto;">

            <img src="<?php if(!empty($vP["photo_thumb"])) { echo "images/profileimages/".$vP["photo_thumb_small"]; }else{ echo "images/profileimages/noPhoto_thumb.jpg"; } ?>"  style=" border: 2px solid #CCC; margin-right: 5px; margin-left: 15px;  margin-bottom: 2px;">


    </span>
    </span>
    </a>

</div>

Answer №1

To achieve this layout, consider creating a table with 4 columns and 2 rows.

<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td>Logged in as:</td>
<td>Gender: Male</td>
<td>Field:1</td>
<td>Field:1</td>
</tr>
<tr>
<td>Andrew</td>
<td>Age: 22</td>
<td>Field:1</td>
<td>Field:1</td>
</tr>
</table>

You can adjust the width of the cells using CSS, such as setting td {width:200px;}. Another approach is to assign a class to each cell like

<td class="cell">Gender: Male</td>
and style it with CSS using .cell {width:200px;}.

If needed, you can also explore using floats and other tricks to achieve the desired outcome.

Answer №2

If you want to display your profile information in HTML, here's how you can do it:

<div class="profile">
    <img src="path/to/your/img.png" alt="Example's Avatar" />
    <p class="login-info">You are logged in as: <span class="username">Example User</span></p>
    <ul class="user-info">
        <li>Gender: Male</li>
        <li>Age: 24</li>
        <li>Member since: 24 Aug 2009</li>
        <li>Currently wearing: Pink T-Shirt</li>
        <li>Email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="402538212d302c25002538212d302c256e232f2d">[email protected]</a></li>
        <li>Another field: Value 1</li>
        <li>Drinking: Coffee</li>
        <li>Mug collection: 300</li>
        <li>Another field: Value 2</li>
    </ul>
</div>

This markup includes an image, login information, and various user details displayed in a structured format. By using specific classes for styling elements, we ensure the content is presented as intended.

.profile {
    padding: 20px;
    background: #333 url('path/to/gradient.png') repeat-x;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.6em;
    font-family: Arial, sans-serif;
    color: white;
    width: 960px;
}

.profile img {
    width: 80px;
    height: 80px;
    border: 1px solid #eee;
    display: block;
}

.profile .login-info, .profile .user-info li, ... 

Separating CSS from HTML allows for easier maintenance and customization. The styling rules define the layout and appearance of each element within the profile box, creating columns with specific widths and margins.

To see this in action, check out the live demo here: http://jsfiddle.net/stEkY/

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

Items seem to vanish into thin air and become immovable when attempting to relocate them

I am attempting to create a unique grid layout with 3x3 dimensions, where each grid item represents a fragment of a single image. These items should have the capability to be dragged and dropped inside another 3x3 grid, in any desired sequence. I have hit ...

How to dynamically alter a PHP variable using a JavaScript button click on the existing webpage

I've spent the last hour scouring stackoverflow for answers to my problem, but trying out solutions has only resulted in errors - perhaps because I'm attempting to implement it on the same page. I've experimented with saving the value to a ...

Unable to retrieve the values from document.getElementById("") or document.getElementById("").innerHtml appears to be malfunctioning

I am currently working on an HTA application that includes multiple <input type="text"> fields for users to input data. My goal is to pass this data to a VBScript for processing. Below is the HTML structure: <div id="tableContent" name="tableCon ...

Problem with special characters in Localstorage for Internet Explorer 8

After developing a jQuery script that retrieves data from a service, stores it in local storage, and displays it on the page upon a specific event, I encountered an issue with displaying Chinese characters only on IE8+ browser. Unfortunately, IE is unabl ...

Unable to interpret the remainder: '('static', filename='main.png')' within the context of 'url_for('static', filename='main.png')'

I am a beginner with django and I'm attempting to display an html page. I have a test HTML page and a URL for testing purposes. When accessing the URL, I encounter the following error: Could not parse the remainder: '('static', filena ...

Reverse all elements on the page except for ::selection

Is there a way to invert the page while keeping text selection unchanged? I attempted to use ::selection to exclude it, but was unsuccessful. Below is the CSS code I used for inverting the page: html { background-color: #131313 !important; filter: cont ...

How to retrieve the current event handler's value with jQuery

To assign an onclick event handler using jQuery, I simply use the following code: $('#id').click(function(){ console.log('click!'); }); Now, my question is how can I retrieve a reference to the function that is currently handling th ...

ASP.NET ensures that the entire page is validated by the form

Is it possible to validate only a specific part of the form instead of the entire page? Currently, when I try to validate textboxes on the page, the validation is applied to all textboxes. Here are more details: https://i.stack.imgur.com/eowMh.png The c ...

List of shapes and text items

I'm encountering some challenges with my list of shapes - could it be that I am approaching it the wrong way? I could use some guidance on what I am trying to accomplish. Check out My Fiddle CSS: #circle { height: 120px; width: 120px; b ...

Slider with Dual Images: A Visual Comparison

I'm currently working on a webpage that features before and after images using a slider based on mouse movement to display both pictures. I am trying to incorporate multiple sliders on the same page but have been facing difficulties in getting them to ...

How can I alter the text color on hover within a Material UI card? My goal is to have the text color change when hovering over the card itself, rather than just the text

When I apply CSS to the card hover effect, it works fine. However, I also want to change the text color along with the card color on hover. card: { maxWidth: 350, height: 300, '&:hover': { backgroundColor: '#373737 !impor ...

Tips for preventing Razor from interpreting special characters as HTML code

I'm encountering an issue with special characters displaying as HTML codes on the page I'm working on. The content is retrieved from a database and shown in readonly input boxes. For example, & is displayed as &. How can I ensure that the ...

How can I combine an ordinary image and a CSS2D image in THREE.js CSS2DRenderer and save them together as a single .jpg file?

After implementing the following code... (1) I successfully saved regular rendered THREE.js scenes as .jpg files; (2) Additionally, I managed to utilize CSS2DRenderer to display CSS2D labels on top of the canvas; (3) Now, my goal is to save the image wi ...

Issues with CSS Min-Height in Various Web Browsers

Lately, I've been working on a website and trying to create a border that surrounds all my content and extends the full length of the page. The #Container div is supposed to expand to fill the entire page. I've tried using min-height:100%; in my ...

Steps for rearranging the order of CSS grid layout

Could you assist me in implementing a grid layout that fulfills these specific criteria? I'm unsure of how to proceed, so any guidance would be greatly appreciated. When there are more than 9 items, the current layout changes the order from top to bo ...

Attempting to showcase JSON response within an HTML page using JavaScript

Can anyone help me troubleshoot my code for displaying JSON data on a web page? Here's what I have so far: <button type="submit" onclick="javascript:send()">call</button> <div id="div"></div> <script type="text/javascript ...

Enable CDATA support in ActionView::Base.full_sanitizer

One method I found helpful was using the ActionView::Base.full_sanitizer.sanitize(value) to remove HTML content. It generally works well, but there is an issue when the value passed into the method is wrapped in because it returns a blank ...

Expanding Headers with JavaScript

Looking to add a Stretchy Header Functionality similar to the one shown in this GIF: Currently, on iPhones WebView, my approach involves calling a Scope Function On Scroll (especially focusing on Rubberband Scrolling) and adjusting the Image Height with C ...

Create Stylish Popups and Spacious Containers with CSS

A unique pure css popup was crafted by merging and . Hovering over "John Smith" triggers the appearance of the popup. The code for this can be seen at http://codepen.io/kikibres/pen/MwEgQX. However, there are some challenges being faced. The aim is to ke ...

What causes the position: sticky; property to fail in React implementations?

Currently, I am facing a challenge in making two sidebars sticky so that they will follow as the user scrolls until they reach the bottom of the page. In my current editing project, this implementation seems to be more complex compared to other programs w ...