2

http://tynesideelectrical.co.uk/

In this website displaying a phone number banner on header. i need to display a 'click to call' image instead of this number banner while browsing from mobile device.

using with CSS.

Any hope. ?

Riasnelli
  • 21
  • 1
  • 2

3 Answers3

3

Using CSS, you can embed images via the background-image property and then combine it with media queries to load different images on desktop and mobile.

/* For desktop */
@media (min-width: 721px) {
  .header {
    background-image: url('img/desktop.png');
  }
}

/* For mobile */
@media (max-width: 720px) {
  .header {      
     background-image: url('img/mobile.png');
  }
}
Pankaj Parashar
  • 9,762
  • 6
  • 35
  • 48
  • My phone has a `max-width` of 980px. You'd be better using `max-device-width` instead and setting that to around 480px. – James Donnelly Oct 31 '13 at 14:05
  • Check out this answer that says not to use `max-device-width` - http://stackoverflow.com/questions/18500836/should-i-use-max-device-width-or-max-width – Pankaj Parashar Oct 31 '13 at 14:09
0

Media Query's are your friend here!

You might want to look into: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries

It checks the device/monitor, and according to that you change the styling.

Kevinvhengst
  • 1,672
  • 4
  • 27
  • 40
0

Theoretically you can use simple

@media handheld {
    /* rules for mobile phone */    
}
@media screen {
    /* rules for computers */   
}

but (new) smartphones make a pretense of they are normal computers and will not react on handheld.

There's no exact way … you can only identify phone by smaller resolution (but seems that not for a long time)

iiic
  • 1,366
  • 2
  • 15
  • 23