Resizing 1) background images and 2) div's containing images

I just created a web page consisting of little more than an image (about 900 pixels) wide which is set at width=100% in a style sheet. It works great, but I'd like to substitute a smaller image (to reduce page loading time) in mobile devices.
If it was a background image, I could just declare two different background images based on screen size, but I don't know of any way to swap between images actually inserted in a page.
So, is it possible to give a background image a width in percentage, similar to a static image? In other words, if my screen was 651 pixels wide, then a static image inside a container spanning the entire screen should also be 651 pixels wide. Can I rig it so that a background image in that container would also be 651 pixels wide?
Of course, the obvious problem is height. If a background image measures 900 X 1200 pixels, and a screen is 600 pixels wide, then even if there's a style that makes the image 600 pixels wide, it would also have to calculate a height of 800 pixels, and I'm guessing that can't be done.
Anyway, I'd just like to know what kinds of tricks one can use in making background images and divs containing static images display in percentages based on screen size.
Thanks.

Use background-size:cover; for your background images.
Further reading: http://css-tricks.com/perfect-full-page-background-image/
EDIT:// For swapping out placed images, it's a little harder to do right now as there is no specified solution from W3C. Some people want to use the srcset attribute, others the <picture> tag. There is no perfect approach right now. See: http://mobile.smashingmagazine.com/2013/08/21/webkit-implements-srcset-and-why-its-a-good- thing/
One idea is you could hide the image and then load a background-image in the container which is smaller in size. But this would likely bloat your HTML and CSS as you use multiple images - the device will also load both images so you don't gain any real advantage unless you intend to show a croppoed or different image.
Other ideas: http://mobile.smashingmagazine.com/2013/07/08/choosing-a-responsive-image-solution/
<div class="image">
     <img src="YourImage.jpg" alt="" width="500" height="250" />
</div>
@media only screen and (max-width: 480px) {
     .image img {display:none;}
     .image {
          background:url("YourImage_Mobile.jpg") no-repeat 0 0;
          background-size:cover;
Another idea is to show/hide the relevant image:
<img src="YourImage.jpg" alt="" width="500" height="250" class="desktop" />
<img src="YourImage_mobile.jpg" alt="" width="300" height="180" class="mobile" />
@media only screen and (max-width: 480px) {
     .desktop {display:none;}
     .mobile {display:block;}

Similar Messages

  • I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?

    I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?  Help!

    If the scan is in B&W, then play with the Threshold setting here
    If it's in Color, then you will have to open the scan in a Raster editing software (like Photoshop) and play with the Brightness/Contrast settings to make the lines bolder.

  • How can I take an item from one image and move it to another image?

    How can I take an item from one image and add it to another image, and rotate it to fit?

    Carefully select the objects of interest in one image and then copy, scale and position them into the other image. Then touch up the composite.
    Have to Love Photoshop for Retouching Images!

  • Is it possible to clone an object from one image and paste it on another image?

    Is it possible to clone an object from one image and paste it on another image in Aperture?

    As Frank said,
    but Aperture has a nice clone tool - the drawback is, that it only works within one image.
    What I sometimes do - as a workaroud, when I want to use the clone brush, is to combine the image I want to clone from and the image I want to clone into, into one single image by printing them together to pdf as jpeg. Then I can clone from the second to the first, for example, to be able to add an fairy to a flower: Picking up the head of the fairy in the right image and brushing it into the left one. Occasionally I prefer the Aperture brush to the Photoshop lasso.

  • How do I save image and text as a single image in InDesign CS5.0?

    How do I save an image and text as one image in InDesign CS5.0? NOT 5.5.
    I need to save the image as a 72-dpi, jpg file for ePub purposes. I designed a book and am handing it off to someone for ePub.
    This is what I've tried:
    1) Copied from InDesign, pasted into a PhotoShop doc as a Smart Object. Saved it as 72 dpi jpg, then imported back into ID.
    2) Took a screenshot of ID page, placed it in PS, saved as 72 dpi, imported into ID
    3) Saved page as a PDF from InDesign, then saved PDF as 72 dpi jpg, then imported into ID.
    4) Save page as a PDF from InDesign, placed into Photoshop and saved
    as 72 dpi, then imported into ID.
    5) Saved as an EPS from InDesign, placed in PS, then imported back to ID.
    In all cases, the type looks terrible. It doesn't seem to matter whether I copy or place into Photoshop, though placing is slightly better.
    HELP!!!

    In all cases, the type looks terrible. It doesn't seem to matter whether I copy or place into Photoshop, though placing is slightly better.
    Naturally what you did will result in rasterized text. Did you preview with high quality settings?
    Are you sure the people who will handle that downstream need pixel images and do you have the exact pixel dimensions needed?
    Why did you place the image back in Indesign, by the way? 

  • Get bounds of image and bounds of frame of image?

    How can I get both the geometric bounds of an image AND the geometric bounds of the frame of the image as I loop through all the images in a document?

    Here's the Apple Script version of the script:
    tell application "Adobe InDesign CS3"
         set TheDocument to active document
         set TheGraphics to all graphics in TheDocument
         repeat with n from 1 to (count TheGraphics)
              set TheGraphic to item n of TheGraphics
              set TheLink to item link of TheGraphic
              set TheImage to parent of TheLink
              set TheFrame to parent of TheImage
              set ImageGB to geometric bounds of TheImage
              set FrameGB to geometric bounds of TheFrame
              set ImageVB to visible bounds of TheImage
              set FrameVB to visible bounds of TheFrame
              set TheText to "Name: " & name of TheLink & return & ¬
                   "Geometric Bounds of Image = " & ImageGB & return & ¬
                   "Geometric Bounds of Frame = " & FrameGB & return & ¬
                   "Visible Bounds of Image = " & ImageVB & return & ¬
                   "Visible Bounds of Frame = " & FrameVB & return & return
              my write_to_file(TheText, true)
         end repeat
    end tell
    on write_to_file(this_data, append_data)
         try
              set the log_file to (path to desktop as text) & "Geometric and Visible Bounds Report" as text
              set the open_target_file to open for access file log_file with write permission
              if append_data is false then set eof of the open_target_file to 0
              write this_data to the open_target_file starting at eof
              close access the open_target_file
              return true
         on error
              try
                   close access file log_file
              end try
              return false
         end try
    end write_to_file
    Kasyan

  • Can I attach a link to one image and then use that linked image multiple times in my site?

    Hi,
    Is it possible to attach a link to an image and then use that image (with link attached) multiple times in my site.
    Thanks,
    Ally

    Use 'Find and Replace'>under the 'Edit' menu.
    Select from 'Find in'- Folder and browse to the folder your website files are kept in to select it.
    Search: Source Code
    In the Find box (but obviously use YOUR image code):
    <img src="images/imageName.jpg" width="200" height="200" alt="" />
    In the Replace box: (use YOUR link and image code)
    <a href="yourLink.html"><img src="images/imageName.jpg" width="200" height="200" alt="" /></a>
    Then select 'Replace All'

  • How to upoload images and give actions to those images

    Hi,
    I want to upload images to view and want to give action to the image.
    insted of creating a button (for eg : save . instead of creating save button i want to upload an image for the this save and once user clicks on image it shouls perform the action like as save button)
    pls guide me on this.
    Regards,
    Pavani

    Hi,
        The image type can be .jpg or .gif. After putting the image in the folder suggested by Armin, do the following :
    1. Create a link to action
    2. In the properties of  this LTA, make the 'image first' property as true.
    3. Now in the image source property, choose component image and select the desired image (one which you  have already put in the folder)
    4. Now declare the action for the LTA.
    The image would appear on the screen and clicking on it would fire the desired LTA.
    Hope this helps.
    Regards,
    Himanshu

  • Upload Images and giving an action to image

    Hi,
    I  want to upload images  and by clicking that image it must go to next view.
    Could you please suggest me some of the steps to upload image and to make an action on image.
    Regards,
    Anitha

    You can use FileUplod UI Element for uploading your photo.
    and to make image as action you can use LinkToAction UI Element and put the full image name(with file Ext) in ImageSource property of LinkToAction UI Element, after that create a action and put the required code for next level of prcessing
    use this running code for uploding you file
    String FileName = "temp;
           InputStream input = null;
           int i=0;
              FileIncreament();
              try {
                        String directory =".\\temp\\webdynpro\\web\\local\\yh1245_ftp"+
                        "\\Components\\com.yash.yh1245.Upload\\"+FileName+wdContext.currentContextElement().getCounter();
                             boolean sucsss = new File(directory).mkdir();
                             if(sucsss){
                                  wdComponentAPI.getMessageManager().reportSuccess("Directory Created ");
                                 File file = new File(directory+"\\"+wdContext.currentContextElement().getResourceURL().getResourceName().toString());
                                  FileOutputStream fos = new FileOutputStream(file);
                                  wdComponentAPI.getMessageManager().reportSuccess(file.getAbsolutePath());
                                  FilePath = file.getAbsolutePath();
                                  wdComponentAPI.getMessageManager().reportSuccess("AbsolutePath......."+file.getAbsolutePath());
                                  if(wdContext.currentContextElement().getResourceURL()!=null){
                                       input = wdContext.currentContextElement().getResourceURL().read(false);
                                       //wdComponentAPI.getMessageManager().reportSuccess("Resource is not null ");
                                       while((i = input.read())!=-1){
                                            fos.write(i);
                                  fos.flush();
                                  fos.close();
                                  wdComponentAPI.getMessageManager().reportSuccess("File Uploaded on server directory ");

  • Issue with images and AP div layers

    Im a bit of a noobie. but i have a problem with this website
    im working on. I have a table with an image in it serving as a
    background for some text i wish to put into it. I use an AP Div
    layer to put in the text on top of the image. Of course when i open
    the page in a full window, it displays properly, but when resizing
    the window, the text shifts as a cause of the div layer not
    moving... Is there a way to fix this or another way to do this
    properly?
    thanks in advance.

    This is a problem with absolute positioned tags it's a CSS
    thing not a Dreamweaver problem.
    You should be staying from layers and using hand CSS with
    divs ID and class. Check out the adobe site for tutorials on using
    Dreamweaver with CSS. You should find these in the designer
    section. They are quite good and they'll give you what you're
    looking for
    Also a good book on this is CSS the Missing Manaul it really
    explains what's happening and going on here

  • How Can I take this image and put it in another image? Basically Background but different

    So, I got photoshop today for a project I have to do and have never used it in my life. I am making a childrens book for school and I am trying to pug the corner pug in this photo onto the couch of the next photo. I am going to use the various expressions of the pug in different settings but I want just the pug I choose to be there withouth the other ones or the white background. Im aware that its watermarked, Im just going to ignore that unless someone has specific instructions on how I can get that off aswell. How do I do this? Please be specific, thanks!

    Open the picture of the pugs. On the Toolbar click the icon for the Lasso tools. In my PSE version this is row 2, column 1 of the Toobar; it might be in a different location in your version. On the tools option bar you will see icons for the different types of lassos. Select the Magnetic Lasso. Click on the pug you want and slowly trace his outline. At the end click again to complete the selection. The pug will be outlined in "marching ants".
    Copy this selection to the clipboard: Edit > Copy.
    Now open the picture of the sofa. Paste the pug from the clipboard: Edit > Paste. The pug will be placed on a new layer in the Layers Palette.
    You will probably want to resize him. To do that, activate the Move tool (row 1, column 2 on my Toolbar). Eight handles will appear around the pug. Holding down Shift, drag any corner handle to resize (Shift preserves the proportions). Also use the Move tool to position the pug where you want him using the mouse. You can also use the arrow keys to fine-tune the position.
    <edited by forum host>
    If when you selected the pug you selected some excess white outside his outline you can remove this with the Eraser tool (row 7, column 1). Similiarly if you had not selected all of the pug you can use the Brush to paint in the rest. You can also use the Eraser for example to flatten the bottom of the pug as I have partially done.

  • How to save appropriate images and then discard the saved images after using.

    Hi,
    The attached program is used for gesture recognition and playing the corresponding audio file for each recognized pattern. It is saving all the images that are captured and is using in pattern matching. if pattern for "A" is captured ,then almost 10 to 15 intermediate images are captured along with pattern "A". If all are pattern matched then audio file of "A" will be played for 4 or 5 times which is not desirable. Also the images saved in the imaq write folder are getting piled up. They should be discarded after they are used up in pattern matching otherwise it would be a waste of system memory. Can anybody  advice in correcting.
    Thanking you. 
    Attachments:
    program help.zip ‏721 KB

    Hi,
    The attached program is used for gesture recognition and playing the corresponding audio file for each recognized pattern. It is saving all the images that are captured and is using in pattern matching. if pattern for "A" is captured ,then almost 10 to 15 intermediate images are captured along with pattern "A". If all are pattern matched then audio file of "A" will be played for 4 or 5 times which is not desirable. Also the images saved in the imaq write folder are getting piled up. They should be discarded after they are used up in pattern matching otherwise it would be a waste of system memory. Can anybody  advice in correcting.
    Thanking you. 
    Attachments:
    program help.zip ‏721 KB

  • I need the ASD 3S144 image and also the ASD 3S146 image.

    Hi,
    I have many Apple desktops and laptops, I need the URL to the ASD 3S138, the ASD 3S144, the ASD 3S 146 and any of the 150's series ASD.
    I've bought about $100,000 of Apple computers over the last 10 years, I think I deserve to be able to diagnosis them with FREE DIAGNOSIS IMAGES, on my own.  So could someone give me the URLs so I can download the diagnosis EFIs?  Thanks.  I'm sure glad Apple isn't too fascist to stop me from figuring out what'w wrong with the Macs they sold me,... that their Stores won't work on, calling them 'vintage'... thanks again.

    Please understand that these forums are composed of Apple users and not Apple employees.  You will have to contact Apple directly regarding your request;
    http://www.apple.com/contact/
    Ciao.

  • How to display image and data in module pool screen?

    Hi,
    I want to display image and relevant data besides the image in module pool screen, I am using docking container to display the image.
    Actually I am able to display image or data any one but not both.
    one more thing I want to display multiple images and their data.
    Please suggest some one if you have any idea.
    Regards,
    Dileep.

    You can try below way, I have used in report.
    DATA: gc_docking              TYPE REF TO cl_gui_docking_container, "#EC NEEDED  "Docking Container
           gc_split                 TYPE REF TO cl_gui_easy_splitter_container, "#EC NEEDED  "Splitter
           gc_top_container         TYPE REF TO cl_gui_container, "#EC NEEDED  "Top Container
           gc_bottom_container      TYPE REF TO cl_gui_container, "#EC NEEDED  "Bottom Container
          gc_document              TYPE REF TO cl_dd_document, "#EC NEEDED  "Document
           gc_events                TYPE REF TO lcl_event_class, "#EC NEEDED  " Local Event Class
           gc_grid                  TYPE REF TO cl_gui_alv_grid, "#EC NEEDED  " ALV Class
    " Creating Docking
    CREATE OBJECT gc_docking
           EXPORTING
             ratio = c_95.
         IF sy-subrc EQ 0.
    * Splitting the Docking container
           CREATE OBJECT gc_split
             EXPORTING
               parent        = gc_docking
               sash_position = c_10 "Position of Splitter Bar (in Percent)
               with_border   = c_1. "With Border = 1 Without Border = 0
         ENDIF.
    *   Placing the containers in the splitter
         gc_top_container = gc_split->top_left_container .
         gc_bottom_container = gc_split->bottom_right_container .
    *   Creating Grid
         CREATE OBJECT gc_grid
           EXPORTING
             i_parent = gc_bottom_container.
       ELSE.
    * Background job handling
         CREATE OBJECT gc_grid
           EXPORTING
             i_parent = gc_docking.
       ENDIF.
    *   Creating the document
       CREATE OBJECT gc_document
         EXPORTING
           style = 'ALV_GRID'.
    Regards,
    Sameer

  • Missing images and not able to use copy and paste anymore - just blank rect

    Hello!
    I've a problem that really scares me.
    I use severall png and pdf images. But at one point keynote looses the media and just displays these grey rectangles instead of some images. I tried to figure out if it just happens with pdf images and replaced the missing pdf images through png24 images with transparency. It first worked fine (they showed up) and then it tells images can not be saved. If I open the presentation again, the images are missing. And it seems that the more images and slides i put in the presentation, the more images are missing…
    But there is more: I even can't copy and paste these images anymore. If I try to copy one of the images I just have replaced (because they have been lost by saving), it just pastes the blank grey rectangle instead of the image.
    This really is a problem because I now have to repetitive tasks (like same animation for the same image in the same size) over and over again. And when I save the doc – they are al gone again…
    It really scares me and I don't have an idea how to solve this.
    It also happens, if I repleace an pdf image with an png image and than try to copy this new png image. However I am able to drag the image from the Finder again.
    I am working on a PB G4, 1.5 GHz, 1 GB RAM.
    My Keynote Version is 3.0.2.
    The Keynote Dokument is saved and opened from a G4 X-Serve wich is only used by Macs (so no Windows Filesystem anywhere). I still have anough space on both, my local and the server volume. I don't transfer the Keynote document. So it should not be a problem with the names on the files… And the files are just exported from Adobe Illustrator (png 24 files with "save for web" and the pdf files are saved as Illustrator pdf) – so they should really be fine and not corrupted…
    At this time the Keynote document has a size of 179 MB (because of a video) and only 16 slides. And the theme was built from scratch – so no import from Powerpoint or so…
    I looked through the Keynote preferences and found a thing like (sorry self-translated from german version to english) "scale placed images to slide-size". I wondered if keynote saves a copy of the sacaled image after that and corrupts the image itself? But I don't think so.
    I've had these problems with earlier versions of Keynote, but it occured just sporadically and I could solve it through pasting it again. But this time I can not solfe it anymore.
    Does anybody encounter same problem? Or has a hint?
    I really would appreciate, because I have to finish the presentation very soon and are not able to work properly with that. Furthermore, I am scared of saving and opinging the presentation again, because the lost files can not be replaced…

    I now have a hint:
    As a colleague said, he encountered some problems with usagerights on our fileserver (XServe). He said he wasn't able to read files he put on the server himself again…
    If this is true, the same could have happened to Keynote for placed images, as Keynote writes these images as separate files in the doc package…
    I will try to work on my local volume and see if it solfes the problem.
    But sooner or later I will have to place the whole thing on the server again…
    Do you think this is the reason?

Maybe you are looking for