Is there a way to set a background css sprites image width?
shop
a{
background-image: url(http://placehold.it/60x60/ff0000/000&text=100)!important;
background-repeat: no-repeat;
display: block;
background-position: -5px -5px;
padding: 0 0 0 30px;
}
https://jsfiddle.net/jb1prcro/
right now the above a tag is 60px width, 30px for the word 'shop', 30px padding left for the cart icon,
because I am using css sprites for the background icons, right now it is showing 60px of that background image instead of just the 30px I want to show.
I also tried background-size: 30px 30px for this A tag, but it doesn't work.
You can use the pseudo-element before:
a{
display: inline-block;
background-position: -5px -5px;
padding: 0 0 0 30px;
height:30px;
vertical-align:middle;
}
a:before {
background-image: url(http://placehold.it/60x60/ff0000/000&text=100)!important;
background-repeat: no-repeat;
width:30px;
height:30px;
display:inline-block;
content:'';
vertical-align:middle;
}
Working example: https://jsfiddle.net/mspinks/jb1prcro/2/
I am not sure what exactly you are trying to achieve, but here's a practical example:
https://jsfiddle.net/ozL0yzuy/
a {
background-image: url(http://placehold.it/60x60/ff0000/000&text=100)!important;
background-repeat: no-repeat;
display: inline-block;
width: 40px;
background-position: -10px -20px;
}
You have to set a width (and actually also a height, which I didn't do in the example) for the element itself (in this case the a tag, which can only be done if its a block or inline-block element). Then you can adjust the background position accordingly.
Related
I have a title bar with a transparent accent at the left end. There's also a solid background color. I need it to be responsive and accept any length of title. IDK why this is such a pain, but I've tried everything.
I've tried a static image as background, but when the title is two lines high, no dice.
If it were a solid icon, it'd be easy: just drop in the image and add the background color. Since there's no such thing as a "transparent image" that trumps a background color, I'm lost.
Here's what the final product needs to look like:
Any ideas on how to combine a transparency with a solid background and not have said background fill in the transparency?
UPDATE: My current code is not great, but here it is. It works well enough for most widths but is a disaster when it gets narrow. I'll try your suggestions and let you know how things work out. THANKS Everyone!!!
HTML
.titlebox-wrap {
width:90%;
position:absolute;
top:-2em;
left:-3em;
margin:0;
padding:0;
}
.titlebox-hook {
background: url("images/blue-cap.png") no-repeat;
background-size:cover;
background-position:left center;
position:absolute;
top:0;
left:0;
width:10%;
height:100%;
z-index:-1;
}
.titlebox-text {
background:#0d2240;
margin:0;
margin-left:9.8%;
padding:.7em 1em .7em 0;
max-width:80%;
float:left;
-webkit-border-radius:.2em 3em 3em .2em;
-moz-border-radius:.2em 3em 3em .2em;
border-radius:.2em 3em 3em .2em;
}
<div class="titlebox-wrap">
<div class="titlebox-hook"></div>
<span class="titlebox-text">THIS STUPID THING NEEDS TO DICTATE LENGTH</span>
</div>
just a fast idea (not garanteed it will work): why not try the inverse of the ornament as an svg (can style the color) in tat blue color and the rest is not too complicated?
Create a background image that's only as wide as the transparent cutout portion, but very tall, with large solid-colored areas above and below the transparent shape — you'll have to decide how many lines of text this design element reasonably needs to accommodate to determine the px height of the image to produce
Use that bg image on a pseudo-element
Position that pseudo-element outside the element that holds the text using negative margin or transform: translateX(), or in a real element that's a flexbox child of the wrapper
Here's an example using flexbox (from https://codepen.io/RwwL/pen/yPOade):
html, body {
height: 100%;
}
body {
padding: 5%;
height: 100%;
font-family: sans-serif;
background: linear-gradient(to bottom, red, orange);
background-size: cover;
background-repeat: no-repeat;
}
.titlebox-wrap {
width:90%;
margin:0;
padding:0;
display: flex;
}
.titlebox-hook {
width: 40px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAMgCAYAAADVw8ezAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAA6hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICAgICAgICAgICB4bWxuczp0a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0mdA0sXNHiAmUPoMSLq42QPEBEqfAUkXN3uAmEDpMyDp4mYPEBMofQYkXdzsAWICpc+ApIubPUBMoPQZkHRxsweICZQ+A5IubvYAMYHSZ0DSxc0eICZQ+gxIurjZA8QESp8BSRc3e4CYQOkzIOniZg8QEyh9BiRd3OwBYgKlz4Cki5s9QEyg9BmQdHGzB4gJlD4Dki5u9gAxgdJnQNLFzR4gJlD6DEi6uNkDxARKnwFJFzd7gJhA6TMg6eJmDxATKH0GJF3c7AFiAqXPgKSLmz1ATKD0GZB0cbMHiAmUPgOSLm72ADGB0mdA0sXNHiAmUPoMSLq42QPEBEqfAUkXN3uAmEDpMyDp4mYPEBMofQYkXdzsAWICpc+ApIubPUBMoPQZkHRxsweICZQ+A5IubvYAMYHSZ0DSxc0eICZQ+gxIurjZA8QESp8BSRc3e4CYQOkzIOniZg8QEyh9BiRd3OwBYgKlz4Cki5s9QEyg9BmQdHGzB4gJlD4Dki5u9gAxgdJnQNLFzR4gJlD6DEi6uNkDxARKnwFJFzd7gJhA6TMg6eJmDxATKH0GJF3c7AFiAqXPgKSLmz1ATKD0GZB0cbMHiAmUPgOSLm72ADGB0mdA0sXNHiAmUPoMSLq42QPEBEqfAUkXN3uAmEDpMyDp4mYPEBMofQYkXdzsAWICpc8bl/YupDfZe0CBhcXGi9efH0B5QKHgNy8MFhb/Az7FmlVpZmalAAAAAElFTkSuQmCC');
background-repeat: no-repeat;
background-position: left center;
}
.titlebox-text {
background:#0d2240;
flex: 1;
color: #fff;
padding :.7em 2em .7em 0;
max-width:80%;
float:left;
-webkit-border-radius:.2em 3em 3em .2em;
-moz-border-radius:.2em 3em 3em .2em;
border-radius:.2em 3em 3em .2em;
}
Here's an example that illustrates how to set up your image, with a semicircle punchout instead of your fancy floral shape, but it'll work the same:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAMgCAYAAADVw8ezAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAA6hpVFh0W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mlVpZmalAAAAAElFTkSuQmCC
Finally did this with Flex
HTML
<div class="fancy-title">
<div class="fancy-cap"></div>
<div class="fancy-text">content</div>
</div>
CSS
.fancy-title {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap:nowrap;
}
.fancy-cap {
background: url("images/blue.png") no-repeat 0 0;
background-size:cover;
background-position:center left;
width:2.7em;
}
.fancy-text {
background:#0d2240;
width:auto;
}
img {
Background: 100%;
background: url();
}
img {
width: 100%;
display: block;
}
Fiddle link:
https://jsfiddle.net/ildaroit/evL7tn6r/
.video-wrapper {
max-width: 640px;
margin: auto;
margin-top: 20px;
}
.video1 {
border: 0px dotted black;
height: 420px;
/*height:50vw;*/
background: url("http://learn.shayhowe.com/assets/images/triangles/triangles.svg") left -3px no-repeat, url("http://learn.shayhowe.com/assets/images/triangles/triangles.svg") right -3px no-repeat;
/* background-position: left, right;*/
background-repeat: no-repeat, no-repeat;
}
How to make the image not overlapping center div content on decreasing windows size?
Like here: learn.shayhowe.com
Now, left and right image overlap .video but need to make it fixed or something else.
Thx in advance!
hello do you mean like this?
https://jsfiddle.net/evL7tn6r/6/
just add a wrapper to your video1
.page{
width:100%; /*this is not really necessary*/
overflow:hidden;
}
and a min-width to the video
you can adjust the min-width to set the minimum space between the graphics
How can I center my footer image when viewed by a mobile device? As it shows now, on an iPhone, the footer image is not centered.
http://driftcoffeehouse.com/test/
#footer .secondary {
background-image: url("http://driftcoffeehouse.com/test/wp- content/uploads/2014/02/footerbar.png");
background-repeat: no-repeat;
border-top: medium none;
margin: -13px 0;
padding: 30px 0 0;
}
This should fix it. I added this, background-position: top center;, to the #footer .secondary rule.
#footer .secondary {
background-image: url("http://driftcoffeehouse.com/test/wp- content/uploads/2014/02/footerbar.png");
background-repeat: no-repeat;
border-top: medium none;
margin: -13px 0;
padding: 30px 0 0;
background-position: top center;
}
Worked for me. Tell me if you have trouble implementing it. Hope this helped, if not just message me by commenting below my answer. :)
Edit:
Fiddle with the problem (Try resizing the fiddle pane to see the problem.)
Fiddle without the problem.
Well there's the necessary stuff to replicate the problem and show the solution.
I am looking to fix my second full width image (the one in the middle of the page) so that is fits horizontally the same as the one above in the header image. Can somebody double check my CSS so see if it is correct. It needs to auto resize to fit the screen like the header image above. When i view it on mobile it is not fitting correctly. Thanks for taking a look.
http://www.jobspark.ca
.fullWidthSectionBG {
background-image: url('http://static.squarespace.com/static/513d5347e4b0abff73be5264/t/519c45c4e4b084baf13d7e27/1369195972115/rocktruck2.jpg');
border-bottom: solid 1px #ddd;
border-top: solid 1px #ddd;
margin-left: -1600px;
margin-right: -1600px;
padding-top:20px;
padding-bottom:330px;
overflow: hidden;
background-position: center;
background-repeat: no-repeat;
background-size: auto;
}
You need to add the height on to your div I think. Here's the fiddle. I just added a height to the div and now it resizes fine... Is that what you needed it to do?
.fullWidthSectionBG {
background-image: url('http://static.squarespace.com/static/513d5347e4b0abff73be5264/t/519c45c4e4b084baf13d7e27/1369195972115/rocktruck2.jpg');
width:100%;
background-position:center;
height:575px;
}
Updated css (still resizes)
.fullWidthSectionBG {
background-image: url('http://static.squarespace.com/static/513d5347e4b0abff73be5264/t/519c45c4e4b084baf13d7e27/1369195972115/rocktruck2.jpg');
background-position: bottom center;
background-size: cover;
height:575px;
background-attachment: scroll;
background-repeat: no-repeat;
}
Is there any way to apply multiple background images using sprites?
something like the below code?
background-image: url("../images/button-sprite.gif"),url("../images/button-sprite.gif");
background-position: right -92px, 0px 0px ;
background-repeat: no-repeat;
font-size: 1em;
margin-right: 5px;
padding-right: 35px;
width:500px;
height:500px
You can have multiple background images
see the EXAMPLE
Here is my css:
.sprite_box
{
background:
url(http://i.imgur.com/On0lt.png) -162px -551px no-repeat,
url(http://i.imgur.com/On0lt.png) -200px -530px no-repeat,
transparent;
height: 24px;
width: 81px;
margin:5px;
}
Read about sprite here
Here you can create sprite image
Here you create css for your sprite image
Yes, you can have multiple background images, but it is limited to box items. There is some info on this at CSS3.info
Yes, you can. The shorthand method is less verbose:
.sprite {
background:
url(http://www.google.com/images/srpr/nav_logo41.png) 0 -243px no-repeat,
url(http://www.google.com/images/srpr/nav_logo41.png) 42px -93px no-repeat,
#ccc;
width: 160px;
}
Note that you can only state one background color, and you state it at the end of the declaration.
See it in aciton http://jsfiddle.net/TMHPh/