Changing the size of a background image is proving to be quite a challenge for me

I'm completely new to HTML and CSS. I've been working through a book titled The Missing Manual, CSS3 but I've hit a roadblock when it comes to changing the size of an image that I want to use as a background. In order to troubleshoot the issue, I created simple HTML and CSS files, but no matter what I try, the background-size property seems to have no effect at all. The image displays correctly and I can adjust the repeat behavior, but altering the size (whether using percentages or pixels) has no impact on the image dimensions. I even attempted converting the image to a PNG format, but unfortunately, this did not remedy the situation either. The image in question, 'sprial.jpg,' measures 292x288 px, making it so small that I might not end up using it after all.

For coding, I am utilizing Notepad++ for writing and Chrome for viewing the HTML file.

body {
  background-image: url(https://cdn.pixabay.com/photo/2017/09/08/21/39/spiral-2730290__180.jpg);
  background-repeat: no-repeat;
  background-size;
  50% 50%;
}
<body>
  <p> Hello
  </p>
</body>

Answer №1

A common mistake seen here is the misuse of a semicolon - many mistakenly write background-size; when it should be written as background-size:.

Answer №2

There seems to be a small error in the code.

backgroud-size: 50% 50%;

It should be working fine now.

REMINDER: Consider using a plugin that can assist you in identifying and correcting simple syntax errors like this one. One recommendation is the Css Explorer plugin available for download here.

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

Locate Item Using Two Tags Within a Division

My goal is to locate the current value, but it is constantly changing. The name attribute "customerNum" is unique. I believe I need to leverage both of these tags. Unfortunately, whenever I attempt to do so, I encounter an error. Is there a way to proper ...

The fixed position element appears to be failing to stay fixed in Google Chrome

Something strange is happening with a fixed position element in Chrome. It is still scrolling with the page even though it should be fixed. To better understand the issue, you can view it on the live site In Firefox and even IE, the "Block 1 Block 2 Block ...

Since updating my background-image, the header images have mysteriously vanished

Currently, I am in the process of building a webpage and want to create a default navigation bar that will be consistent across all pages. Below is the code snippet from the file where I wish to include my navigation bar: <html> <head> < ...

How to customize JavaFx context menu appearance using CSS to achieve a full-width background color

I am trying to customize my context menu, but I'm having trouble with the white space between the menu item and the context menu border. Here is an example: view the rendered context menu with CSS styles What I want is for the color to fill the entir ...

Illuminate a group of items when hovering over them

While attempting to change the color of 1 to 5 elements on mouse hover based on the data-rating tag, I am encountering a few issues. The data is retrieved correctly, but there are some problems: The function is being called 5 times each time there is a ho ...

Tips for transforming a container div into a content slider

Working with Bootstrap 3, a custom div has been created as shown below: <div class="second-para"> <div class="container"> <div class="second-section"> <div class="c ...

Flexible DIV Grid Design with Overlapping Absolute Div Elements

My goal is to replicate the layout shown in this screenshot view screenshot here I want the layout to be responsive, with DIV B moving below DIV A when the screen is resized. DIV B is positioned absolutely to cover content and DIV C. Both DIV C and DIV ...

Encountering an unforeseen issue with my code

I am currently developing a web application in advanced Java and incorporating various external libraries such as choosen.js, summernote.js, Bootstrap, BootstrapValidator, etc. I have encountered some errors and am struggling to pinpoint the root cause of ...

Python Selenium: Having trouble clicking a button without any element identifiers such as id, value, or name associated with the button tag

I'm experiencing trouble with Selenium as it attempts to interact with the "Become A Member" button found on this link: . Here is the HTML code relating to the button: https://i.sstatic.net/Pjeu3.png Despite my efforts in using various methods such ...

Differences in behavior of multiple select with track by in Angular versions above 1.4.x

I recently upgraded my product from Angular 1.2.x to 1.4.x. Since updating to angularjs 1.4.x, I've encountered an issue: What I have: I included code snippets for both angular 1.2.0 and 1.4.8. You can check out the comparison on JSFIDDLE. Explanat ...

Tips on creating a line break within a text box

There is a gap between the text boxesIn the first row, I used text boxes with labels. When I use a text box with a label, the text box is attached to the text box in the first row. I tried using a break line but in mobile view, there is a gap showing be ...

Fix background transition and add background dim effect on hover - check out the fiddle!

I'm facing a challenging situation here. I have a container with a background image, and inside it, there are 3 small circles. My goal is to make the background image zoom in when I hover over it, and dim the background image when I hover over any of ...

Styling the CSS tables with alternating row styles for rows 1 and 2, followed by a different style for rows 3 and 4. This pattern will repeat

I've been struggling to create a CSS table style using tr:nth-child to alternate row colors: Row 1 - Blue Row 2 - Blue Row 3 - White Row 4 - White ... and so on. I can't seem to get it right! Can anyone help me out with this? Appreciate an ...

The NgModel function within *ngFor is executing more times than necessary during initialization

Displayed on screen are a list of tutorials with check boxes next to each tutorial's states. These tutorials and states are pulled from the database, each tutorial containing a name and an array of associated states. Here is the HTML code: <div c ...

The functionality of Access-Control-Allow-Origin is not effective in Chrome, yet it operates successfully in Firefox

I'm facing an issue with my code in the HTML file. I have a second file that I want to load content from, and both files are located in the same directory <div id="mainMenu"></div> <script> $(function() { $('#mainMe ...

What is the best way to enlarge an image while keeping it contained within a card using Bootstrap?

Is it possible to create a visually appealing card similar to the image provided using Bootstrap 5.3.3 and HTML on a website? https://i.sstatic.net/OH4U0.png ...

Discovering the precise Offset value for a Div element

Looking for a way to identify the unique value of each div on my HTML page, even as offset values change with each refresh. Any suggestions or methods that can help achieve this? ...

What is preventing me from editing the contents of this div?

Hi there, I'm having an issue with changing the content of the "Emps" div in the EmployeeInformation.html file while on the MainScreen.html page. I'm trying to replace the text "DDDDDDDDDDDDDDDDDDDDDD" with the content from the Personal.html file ...

Looking to perform an Ajax call to update a Rails model using HTML5 contenteditable, but encountering an issue where it creates a new

I am in need of assistance to update the plots of a story using HTML5 contenteditable feature. Below is the code snippet: Refer to file# for editing multiple plots <div id="editable" contenteditable="true"> <%= simple_format p.description %&g ...

Text seems to be more robust when placed on a dark backdrop

I am currently facing an issue with fonts, particularly Google's Roboto font. In my tests, I have noticed that the font appears bolder on dark backgrounds (using Chrome 62.0.3202.62 on OSX Sierra 10.12.6), while it looks fine on Google's dark fon ...