Transitioning to mobile-friendly web design

Just completed my very first page for a personal portfolio website. As a novice in web development, I made the width of my site 1600px to match the background image.

Now, my goal is to make the page responsive. However, when I adjusted the width to 100%, the banner div shifted to the left instead of staying centered.

Below is a snippet of my code:

<body>

<div id="banner"> 
   <div class="container_12">
        <div class="grid_7 prefix_5" id="navbar">
            <ul>
              <li><a href="index.html" title="Gelo Lopez">Home</a></li>
              <li><a href="Project Management.html" title="Gelo Lopez Work" target="_blank">Portfolio</a></li>
              <li><a href="http://gelolopez.wordpress.com">Blog</a></li>
              <li><a href="/contact" title="Contact Gelo Lopez">Contact</a></li>
            </ul>
        </div>
        <div class="grid_10" id="bannertext">
            <h1>Hello!</h1>
            <div class="clear"></div>
            <p>Hi, I am Gelo Lopez, an emerging digital marketing and PR Professional. I create stories for brands. I am the social media primmadonna</>
            <p id="bannerbutton"><img src="Assets/Images/bannerbutton.png" width="171" height="44" alt="Gelo Lopez Portfolio" /></p>
        </div>     
   </div>
   </div><!--end of banner-->

CSS:

body {
width: 100%;
color: #5a5959;
font-size: 18px;
font-family: "Lao UI"; 
}

/* sections*/
#banner {
background-image: url(../Images/Banner-background.png);
height:660px;
color: #fff;
font-size: 24px;
}

Using a 960 gs template with 12 columns, I placed the container_12 div under the banner id to center the content on the page.

Seeking assistance from anyone who can help me resolve this issue.

Answer №1

It seems like the issue is with the background image getting cut off on the right side, rather than the banner div actually being shifted to the right. The <div> element acts as a block level element and will fill its parent container, which in this case is set to 100% width.

If you're comfortable using CSS3, you can try adding background-size: contain to the #banner selector to scale your background image to fit the content area.

For more information, you can visit: http://www.w3schools.com/cssref/css3_pr_background-size.asp

You can also view a JSFiddle example here: http://jsfiddle.net/davidpauljunior/LCFun/

Answer №2

To achieve the desired effect with your background image, you may want to experiment with the background-position CSS property. Consider adding the following line of CSS code:

background-position: top left; 

Furthermore, since you are working on a responsive website, it's important to keep in mind that your background might not fill certain screen sizes that were not originally designed for. You may need to either repeat the background or fix it accordingly depending on your requirements. For more information on background repetition, you can refer to this link: http://www.w3schools.com/cssref/pr_background-repeat.asp

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

Bootstrap failing to apply custom CSS styles

I'm fairly new to Bootstrap and I'm currently working on creating a basic blog within my Django project. It seems that my custom CSS is not functioning properly alongside Bootstrap's, and adding inline styles to each element is proving to be ...

Center aligning elements in React using CSS with HTML can be achieved through Flexbox. However, sometimes images

Currently, I'm in the process of developing a website with react and I've encountered an issue with centering elements vertically on the left and right sides. It's been troubling me for a few days now and I haven't found a solution yet. ...

Make Bootstrap Panel Full Width with Highcharts Data

I am currently working on displaying graphs using the Highcharts library on three televisions. All televisions have a FULL HD resolution of 1920 x 1080. I have one Bootstrap panel containing a graph in the panel-body. <div class="panel panel-blue"> ...

Modify the background color of a particular TD element when clicking a button using JavaScript and AJAX

When I click on the "Active account" button inside the designated td with the <tr id="tr_color" >, I want the value "1" to be added to the 'active_account' column in the database. I have been successful with this functionality. However, I a ...

Glitch with menu presentation in Safari browser

I'm currently working on a website for a client who specifically wants a traditional, non-responsive design. The site has been successful over time, but I've encountered an issue with the menu display in Safari. While it looks fine on other brows ...

Steps to create a "reset fields" option for specific input fields

Is there a way to create a link that clears the input fields in a specific column? I have managed to style a button to look like a link: <input type="reset" value="clear fields" style=" background:transparent; border: none; color:blue; cursor:pointer"& ...

Tips for refreshing a page upon submission

My Bootstrap Modal contains a form with Submit and Cancel buttons. The cancel button is working correctly and closes the Modal successfully. However, when I click on the Submit Button, the form submits successfully to the Web Service but the Modal does not ...

What is the best way to automatically populate the date and time fields in PHP MySQL without manual input?

Is there a way to automatically populate these two input fields without any manual input? <input type="time" name="Time" id="Time" value="" /> I am looking for a solution to automatically fill the date and ti ...

Displaying PDF files on the internet without allowing them to be downloaded

How can I display PDF files on my website without allowing them to be saved or downloaded? Is there a way to prevent browsers from saving or downloading the PDF files? ...

Do the last block in the table occupy the remaining space in the row?

Trying to create an HTML email calendar and struggling with getting the last td to fill the remaining space without affecting the width of other rows. Is there a way to increase the width of just the 4th block on the last row to fill the empty space? Here ...

Update the class of pagination to "active" using jQuery

I need assistance with pagination. Here's the code I have so far: <?php for($i = 1; $i<=10; $i++){ ?> <a class="pagenumber" href="?p=<?php echo $i; ?>"><?php echo $i; ?></a> <?php } ?> What I want to d ...

Disabling the default validation message in HTML form inputs

Is there a way to change the default message that appears when submitting an empty HTML text input? I would like the box border to turn red instead. Can anyone help me achieve this? Below is the code for the text input box: <div class="input-group ...

I experienced issues with the brackets software freezing up while using the Bootstrap min CSS file

Recently, I've been using brackets as my text editor and have run into an issue with the bootstrap.min CSS file. For some reason, it keeps freezing whenever I try to load it in brackets. Oddly enough, HTML files work perfectly fine, but ...

Utilizing JavaScript to conceal div elements within a ul container

How can I hide specific div tags inside a ul tag using JavaScript? All div tags are currently getting hidden when I use the id of the ul tag. However, I need only the first div tag to be shown and the rest to be hidden. Here is the HTML code: <ul clas ...

Set the CSS/HTML to make two child elements occupy 50% of the height of the parent container div

This task seems deceptively simple, yet I am struggling to find a straightforward solution. Language: (HTML) <div class="col-6-12 subcontent-outer"> <div class="subcontent"> <h1>Header</h1> ...

Unable to locate the specified CSS file

I've been diving into the world of NativeScript and exploring the tutorials provided at . However, I'm facing an issue with getting the platform specific CSS to work properly. Every time I try to run the code, I encounter the following error mess ...

Avoiding the separation of hyphenated words when they overflow on a new line

My code is designed to limit text to two lines and show an ellipsis if there is more content. However, I am facing an issue with hyphenated words like "breath-taking" not being treated as one word. Instead, they are often cut off at the end of the second l ...

Scroll upwards within a nested div

Is there a way to smoothly animate the content of the inner div upward without requiring any button clicks? Also, is there a method to trigger an event once the animation has completed? ...

Unveiling the intricacies of CSS specificity

Struggling with the specificity of this particular CSS rule. Despite researching extensively, I still can't seem to grasp it. Can someone help me determine the specificity of the following: #sidebar h1, p em, p a:hover{ ... } ...

Find the nearest class name in proximity

I am attempting to find the closest anchor element with a class that has been clicked. However, not all links will have a class assigned to them, so I need to consider the parent class as well. Since the class names will vary, hardcoding specific class nam ...