background-image

Background images: how to fill whole div if image is small and vice versa

╄→尐↘猪︶ㄣ 提交于 2019-11-27 18:04:53
I have three problems: When I tried to use a background image in a smaller size div, the div shows only part of image. How can I show the full or a specific part of image? I have a smaller image and I want to use in a bigger div. But don't want to use repeat function. Is there any way in CSS to manipulate the opacity of an image? yossi Resize the image to fit the div size. With CSS3 you can do this: /* with CSS 3 */ #yourdiv { background: url('bgimage.jpg') no-repeat; background-size: 100%; } How Do you Stretch a Background Image in a Web Page : About opacity #yourdiv { opacity: 0.4; filter:

How to stretch the background image to fill a div

偶尔善良 提交于 2019-11-27 17:46:07
I want to set a background image to different divs, but my problems are: The size of image is fixed(60px). Varying div's size How can I stretch the background-image to fill the whole background of the div? #div2{ background-image:url(http://s7.static.hootsuite.com/3-0-48/images/themes/classic/streams/message-gradient.png); height:180px; width:200px; border: 1px solid red; } Check the code here. hendos43 Add background-size:100% 100%; to your css underneath background-image. You can also specify exact dimensions, i.e.: background-size: 30px 40px; Here: JSFiddle You can use: background-size:

CSS: background image on background color

巧了我就是萌 提交于 2019-11-27 17:45:45
I have panel which I colored blue if this panel is being selected (clicked on it). Additionally, I add a small sign ( .png image) to that panel, which indicates that the selected panel has been already selected before. So if the user sees for example 10 panels and 4 of them have this small sign, he knows that he has already clicked on those panels before. This work fine so far. The problem is now that I can't display the small sign and make the panel blue at the same time. I set the panel to blue with the css background: #6DB3F2; and the background image with background-image: url('images

CSS show div background image on top of other contained elements [duplicate]

最后都变了- 提交于 2019-11-27 17:27:30
问题 This question already has an answer here: CSS background image on top of <img> 2 answers Not sure if this is possible and how, but I tried playing around with the z-index of the elements in my code with no success. I have a div element that has a background image set in css. inside the div, i have other elements, like div and img. I am trying to have the main div that contains the background image stay on top, since I want that background image to show on top of the other elements (this

How do I stretch a background image to cover the entire HTML element?

邮差的信 提交于 2019-11-27 17:22:15
I'm trying to get a background image of a HTML element (body, div, etc.) to stretch its entire width and height. Not having much luck. Is it even possible or do I have to do it some other way besides it being a background image? My current css is: body { background-position: left top; background-image: url(_images/home.jpg); background-repeat: no-repeat; } Thanks in advance. Edit: I'm not keen on maintaining the CSS in Gabriel's suggestion so I'm changing the layout of the page instead. But that seems like the best answer so I'm marking it as such. Nathan <style> { margin: 0; padding: 0; }

Android: textColor of disabled button in selector not showing?

妖精的绣舞 提交于 2019-11-27 17:19:28
I am trying to make a button with a selector my button can have the following states: Enabled/Disabled Pressed/Not Pressed According to the states mentioned above. I need to manipulate the button's: Text color background image The button starts off my being disabled so it should have the disabled textColor and the disabled button background. But I can see the default textColor (specified in style) and NO background image! Here is my selector button_selector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state

100% width background image with an 'auto' height

萝らか妹 提交于 2019-11-27 17:09:23
I'm currently working on a mobile landing page for a company. It's a really basic layout but below the header there's an image of a product which will always be 100% width (the design shows it always going from edge to edge). Depending on the width of the screen the height of the image will obviously adjust accordingly. I originally did this with an img (with a CSS width of 100%) and it worked great but I've realised that I'd like to use media queries to serve different images based on different resolutions - let's say a small, medium and a large version of the same image, for example. I know

Background image in a JFrame

空扰寡人 提交于 2019-11-27 15:49:23
This question has been asked a lot but everywhere the answers fall short. I can get a JFrame to display a background image just fine by extending JPanel and overriding paintComponent, like so: class BackgroundPanel extends JPanel { private ImageIcon imageIcon; public BackgroundPanel() { this.imageIcon = Icons.getIcon("foo"); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(imageIcon.getImage(), 0,0,imageIcon.getIconWidth(),imageIcon.getIconHeight(),this); } } But now, how do you add a component on top of that background? When I go JFrame w = new

JPanel with image background

三世轮回 提交于 2019-11-27 15:36:30
How to put image background on JPANEL? JPanel pDraw = new JPanel(new GridLayout(ROWS,COLS,2,2)); pDraw.setPreferredSize(new Dimension(600,600)); //size of the JPanel pDraw.setBackground(Color.RED); //How can I change the background from red color to image? Here's an explanation. It is probably easiest to load the Image into an ImageIcon and display it in a JLabel , however: To directly 'draw' the image to the JPanel, override the JPanel's paintComponent(Graphics) method to something like the following: public void paintComponent(Graphics page) { super.paintComponent(page); page.drawImage(img,

How to use CSS media query to scale background-image to viewing window

大憨熊 提交于 2019-11-27 15:20:08
问题 I have this large image as a background for a website: body { background: #000 url(/assets/img/living.jpg) no-repeat center center; background-attachment: fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; height:100%; } But on my mobile device (iPhone 4S - Safari), the background-attachment: fixed does't seem to be having the same effect as it would on a desktop. Why is that and can I use a media query to fix that? 回答1: Try