How do I set a background-color for the width of text, not the width of the entire element, using CSS?
By : Aria
Date : March 29 2020, 07:55 AM
To fix this issue Put the text in an inline element, such as a . code :
<h1><span>The Last Will and Testament of Eric Jones</span></h1>
h1 {
text-align: center;
}
h1 span {
background-color: green;
}
|
How to change the background color by the the width of element?
By : divakar
Date : March 29 2020, 07:55 AM
will help you Since you're using inline styles you can use the style property of the div to get the width in % code :
var currentWidth = $('.progress-bar')[0].style.width;
if (parseFloat(currentWidth, 10) < 100) {
$('.progress-bar').css('background-color','red');
}
$('.progress-bar').each(function(){
var currentWidth = this.style.width;
if (parseFloat(currentWidth, 10) < 11) {
$(this).css('background-color','red');
}
});
|
Changing the background color and width of the body element
By : Clint
Date : March 29 2020, 07:55 AM
To fix the issue you can do You're actually doing it, except when you don't declare a background color for the html element, it then takes the background color of the body element. Hence, you're not seeing the difference. Simply give the html element a different background color, and also give body some height: code :
html {
background-color: red; /* new */
}
body {
border: 1px solid black;
width: 500px;
height: 500px; /* new */
margin: 0 auto;
background: black;
}
|
Show background-color on full width of child element of horizontally scrolling element
By : xXOMAROVSKYxX Gamer
Date : March 29 2020, 07:55 AM
|
CSS: Background Color on Element With Automatic Width
By : L K Dsouza
Date : March 29 2020, 07:55 AM
wish helps you The problem domain. I would like to style a HTML list using CSS. The list will serve as a navigation bar and always be on screen. To avoid wasting screen space, the menu should by default be in a collapsed state and only expand on mouse-over. , The simple answer is to use set your li elements to float, like this: code :
/* Main topic entry */
#navigation > ol > li{
white-space: nowrap;
float: left; /* Add this to show background when hovering */
background-color: #333; /* dark grey */
color: white;
overflow: hidden; /* Only show the number until hover */
width: 30px; /* 40px minus the OL’s padding */
|