I'm having troubles with this - The images are not displaying
<div class="carousel-inner">
#foreach ($model->pictures as $picture)
<div class="fill"
style="background-image:url({{ URL::asset($picture->path) }});">
</div>
<!-- {{ HTML::image($picture->path)}} -->
#endforeach
</div>
if I go to the view source the image is alright, actually I pasted the result in the url and works. By the way in the example i have a commented line that works, but I need the image as a background in a div and not actually as an html tag.
What could it be?
the fill class on css:
.fill {
width:100%;
height:100%;
background-position: center;
background-size: cover;
}
It seems that the class "fill" doesn't have the height nor the width. Since you are defining a background for an element that does not have any size, the element itself (ie: the div) is now being showed.
You can resolve this by defining the width and height, like this:
<div class="fill"
style="background:url({{ URL::asset($picture->path) }}); no-repeat;
background-size:269px 95px;height:95px;width:269px">
</div>
Try this:
<div style="height:100px;width:100px;background-image:url('{{ asset('http://www.example.com/images/image.png') }}'); border-radius: 5px;position:relative">
Instead of using:
URL::asset($picture->path
You can use the absolute path to the image.
For example:
http://www.example.com/images/image.png
Also, try using width in px instead of in %
Note: It is better to avoid inline styling but since you are already using it for the background-image, I would just go ahead!
Related
I am using Webpack to load an image to use as a background image. When I apply it using CSS, the div takes on any property I give it other than a background image..
.cover {
background-image: url(../assets/images/childcarer_background.jpg);
background-size: cover;
min-height:500px;
}
<body>
<div class="container-fluid">
<div class="row">
<div class="cover">
</div>
</div>
</div>
<script src="homepage.js"></script>
</body>
When I inspect this in Chrome dev tools, the image is being loaded (I can access it directly) and if I copy the style from the .cover and apply it to element.style within Developer Tools, the style is applied as expected..
It will even overwrite the style when I apply it directly to the element...
This works, but obviously isn't sustainable.
If I inline the style, it works..
<div class="row" style="background-image:url(2769a294377fdc1af5fa011c9bedc6a0.jpg);">
<div class="container">
</div>
</div>
but if I try to make the stylesheet background !important...
It overwrites the background image with a blank background!
Why is this happening?
Try adding !important to your background element. So...
.cover {
background-image: url(../assets/images/childcarer_background.jpg) !important;
background-size: cover;
min-height:500px;
}
try but eliminating space between the colon and url. no space should solve it.
.cover {
background-image:url(../assets/images/childcarer_background.jpg) !important;
my html looks like this:
<div class="container">
<div class="header-content">
hello!
</div>
</div>
i've recently come into a situation where I need the 'header' to be 100% the window for a full-width background. usually i would do this css:
<div class="header-background-color">
<div class="container">
<div class="header-content">
hi!
</div>
</div>
</div>
unfortunately, i am fairly deep into a framework and can't wrap the container. i need to construct it within the container.
<div class="container">
<div class="header-background-color">
<div class="container">
<div class="header-content">
hi!
</div>
</div>
</div>
</div>
i can't figure out a way to accomplish this, and am wondering if this is possible.
if i use this css for header-background-color
background: blue;
left:0;
position: absolute;
width: 100%;
the element looks right, but the page flow is interrupted.
does anyone know if my target goal is reachable?
i made a bootply to illustrate this http://www.bootply.com/129060
You can use a child (>) selector to select the first container element and set its width to 100% and remove the padding.
.example-3 > .container {
width: 100%;
padding: 0;
}
This assumes you'll always have a wrapper around it with a unique class name (or use body if it's the first div), but this also allows you to remove the position: absolute which is causing the overlap and the height can stay dynamic.
See forked bootply: http://www.bootply.com/129065
I've added a button that inserts a paragraph into the div so you can see how it's not affected by changes in height.
Only thing I can think of is using a dumby element to maintain the vertical space (i.e. set the height), and then use absolute positioning on the full width content (as you mention). This is really ugly and won't be a good solution if the height of the content is dynamic.
See #content_dumby element in forked bootply: http://www.bootply.com/129063
I want to create a small white div/background at the top of this site.
http://bit.ly/ZgawU6
The front page shows it correctly, however I've made this with a background-image. When the same background image is used on a page like this: it's at 50% or something, and top:0 won't work.
Can anyone point me in the right direction?
Thanks!
http://bit.ly/1311wSB
What I did was wrap the div with the class of navigation container with another wrapper div, lets call it outer-navigation-wrapper then applied this css.
HTML:
<div class="outer-navigation-wrapper">
<div class="container navigation-container">
...
</div> <!-- end navigation-container -->
</div> <!-- end outer-navigation-wrapper -->
CSS:
.outer-navigation-wrapper {
background: #fff;
height: 60px;
}
Hoping someone can help me out as I'm still pretty new to the whole web design thing. I'm using CSS to create a container wrapper. As you can see from the code I have a bottom, top and center image. When I was using JPEG images everything lined up correctly, however I needed to switch to PNG image files (to take advantage of transparency) and now the top and bottom sections of the wrapper are offset.
**Here is a live link: storrepictures.weebly.com/projects.html
-Please find an image of the resulting problem here: http://i.imgur.com/YnTS8.png
-This is how it looks when I use JPEGs instead of PNGs: http://i.imgur.com/2WMFN.png
Here is my CSS code:
#wrapper {
background: url(containerbg.png) center repeat-y;
}
#wrappertop{
background: url(containertop.png) top center no-repeat;
}
#wrappertbtm{
background: url(containerbtm.png) bottom center no-repeat;
padding-bottom: 65px;
}
And here is the body portion of the HTML file:
<div id="wrapper">
<div id="wrappertop">
<div id="wrappertbtm">
<div id="container">
<div id="header">
<div id="headerleft">{logo max-height="60"}</div>
<div id="navigation">{menu}</div>
</div>
<div id="content">{content}
<div id="footer">{footer}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
check height add width of jpeg and png..
may be both are different.
I am not sure but i think you can solve your problem by giving them same height and width..
I think your PNG images are not sliced properly check it the exact width & height of that.
Whereas they are PNG or JPEG they will come at their exact position if they sliced properly so the problem in not transparency the problem can be improper slicing of image....
And if you will give us the live demo than we would be able to see deeply the exact bugs..
Using a method I've done before but having issues. Not sure if it's a sprite or what.. Basically you have two versions of an image saved into one file with them stacked on top of each other and use CSS to adjust the margins when hovering. Here's an example of it working successfully: http://minimalpluscreative.com
Trying to do the same thing here, but running into issues with overflow:hidden; not working. Instead, the the full (double) image is shown. Here's what it looks like: http://cl.ly/023p1I1D1W0W3a1T1q1R It should be just the top half of the image with overflow:hidden; preventing the other half from showing.
Help? Some kind of syntax error I'm sure...
HTML:
<div id="work" class="sub">
<h3>MUSIC VIDEOS</h3>
<img id="show_fire" class="thumbnail sprite" src="images/daniel_gomes_soundoffire_sprite.png" />
</div>
CSS:
.sprite {
width:140px;
height:61px;
overflow:hidden;
}
.sprite:hover {
margin-top:-61px;
}
I've never seen this done before except with background images, but I don't see why not… it just seems like you need a lot of extra css, and extra html to get it to work as opposed to a background image.
As was said earlier, it's hard to see the problem without seeing your actual code in context, but based on what I see, there could be a few potential things wrong:
You need to wrap the image in a containing element, and assign the width, height and overflow to that. Hidden overflow will hide what's outside of the boundaries that div contains. The image element is the image, it doesn't contain the image, so setting it to overflow:hidden isn't going to hide andything, and assigning it a width will just resize it, not "crop" it (which is the effect you're going for). So you'd need something like:
<div id="work" class="sub">
<h3>MUSIC VIDEOS</h3>
<a class="sprite" href="#">
<img id="show_fire" class="thumbnail" src="images/daniel_gomes_soundoffire_sprite.png" />
</a>
</div>
with this css:
.sprite {
width:140px;
height:61px;
overflow:hidden;
}
.sprite img {
margin-top: 0;
}
.sprite:hover img {
margin-top: -61px;
}
I suggest you use 'a' as the containing element, as not all browsers will recognize the hover pseudo-class on tags other than anchor tags.
I know you think using an image instead of a background image is simpler, but using background images, you can accomplish all this with only one element and less css.
In the example site you refer to, the overflow:hidden property is set on the outer 'div#a'
'div#work' in your code should have it's overflow set to hidden.
Thus when you change the margin on your image it will move within the frame of your outer div.
Additionally I had to add a tag name to the hover declaration.
<html>
<head>
<style>
#work{
position:relative;
overflow:hidden;
width:140px;
height:61px;
}
div.sprite {
margin-top:0;
}
div.sprite:hover {
margin-top:-61px;
}
/* instead of an image */
.sprite div{
height:61px;
}
.red {background:red}
.blue {background:blue}
</style>
</head>
<body>
<div id="work">
<div class="sprite">
<div class="red">a</div>
<div class="blue">b</div>
</div>
</div>
</body>