Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: position a icon

  1. #1
    Join Date
    May 2012
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default position a icon

    Hi

    I need to get a phone icon in the same place on different screen sizes on a website

    I have tried using different css but at the mo I have currently have the following
    Code:
    <div class="header-phone-icon">
    <img src="images/pic-1.png" alt="" title="">
    </div>
    I tried giving a id to the img itself with the following css but did not work
    Code:
    .header-phone-icon {
    float: left;
    position: relative;
    }
    
    #phone-icon {
    position: absolute;
    }
    do I have to use different media query rules for the different screen sizes such as the following

    768px – 980px for iPad and other tablets
    980px and upwards for desktop monitors
    1200px and upwards for larger desktop monitors

    Reason is because I have a client whose website I done but was fixed widths so was all centered but he wants it to cover the whole width of the screen

    Thank you in advance

    Kind regards

    Ian
    Last edited by Beverleyh; 06-15-2015 at 12:16 PM. Reason: formatting

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    You might need Media Queries but it depends on the effect you want to achieve - "in the same place on different screen sizes" could be interpreted in different ways, and could be relative to the viewport or website layout.

    You could try something like;
    Code:
    .header-phone-icon {
    position: absolute;
    top: 1em;
    left: 1em;
    }
    But for specific help, we'd need a link to your page and possibly a mockup image to illustrate placement at a variety of breakpoints.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    May 2012
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Beverleyh View Post
    You might need Media Queries but it depends on the effect you want to achieve - "in the same place on different screen sizes" could be interpreted in different ways, and could be relative to the viewport or website layout.

    You could try something like;
    Code:
    .header-phone-icon {
    position: absolute;
    top: 1em;
    left: 1em;
    }
    But for specific help, we'd need a link to your page and possibly a mockup image to illustrate placement at a variety of breakpoints.
    Hi Beverleyh

    Thank you for the reply, appreciate it

    I did try that but the icon is not in the same place horizontally on a 1280 screen size to a 1920 screen size

    The link to the site I am doing is below

    http://www.broadwaymediadesigns.co.u...nett/index.php

    I want the phone icon to be next to the phone number just to the left of it

    Hope that helps

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I want the phone icon to be next to the phone number just to the left of it
    OK - maybe start by putting the .header-phone-icon div inside the div that's holding the phone number - this would be one easy way to get the phone icon to "follow" the phone number, barring a bit of extra CSS and positioning - mostly display: inline-block; to make the icon sit alongside and not occupy its own line.

    Another idea (probably better than above) could be to use a pseudo element. So you'd remove the .header-phone-icon div but add the image into a pseudo element that "follows" the phone number instead.

    CSS for the pseudo element might look like this;
    Code:
    .header-number::before {  
    	content: " ";
    	display: inline-block;
    	width: 1em;
    	height: 1.35em;
    	vertical-align: middle;
    	background: url(images/pic-1.png) center no-repeat;
    }
    Pseudo elements work in all modern browsers and IE8+

    See how that goes and post back with the results.
    Last edited by Beverleyh; 06-15-2015 at 01:12 PM. Reason: details
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    May 2012
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Beverleyh View Post
    OK - maybe start by putting the .header-phone-icon div inside the div that's holding the phone number - this would be one easy way to get the phone icon to "follow" the phone number, barring a bit of extra CSS and positioning - mostly display: inline-block; to make the icon sit alongside and not occupy its own line.

    Another idea (probably better than above) could be to use a pseudo element. So you'd remove the .header-phone-icon div but add the image into a pseudo element that "follows" the phone number instead.

    CSS for the pseudo element might look like this;
    Code:
    .header-number::before {  
    	content: " ";
    	display: inline-block;
    	width: 1em;
    	height: 1.35em;
    	vertical-align: middle;
    	background: url(images/pic-1.png) center no-repeat;
    }
    Pseudo elements work in all modern browsers and IE8+

    See how that goes and post back with the results.
    Hi Beverley

    The second option works perfect, thank you so much, so the following CSS tells where to position the image etc. so for example it tells it to position it before the header-number div, that right?
    Code:
    .header-number::before {  
    	content: " ";
    	display: inline-block;
    	width: 1em;
    	height: 1.35em;
    	vertical-align: middle;
    	background: url(../images/pic-1.png) center no-repeat;
    }
    might be able to help bit further if ok, the client want's it to fit the screen instead of being centered so what I have done is take out the header divs and place them above the main wrapper div and with the footer divs I have placed them after the closing wrapper div tag so the header and footer go all the way across the whole width of the screen so it becomes responsive in a way, is that ok way to do it?
    Last edited by Beverleyh; 06-15-2015 at 01:31 PM. Reason: formatting

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    so for example it tells it to position it before the header-number div, that right?
    Spot on .element::before puts something before/left of, and .element::after puts something after/right of the element.

    There are loads of fancy things you can do with them - take a look here for ideas: https://css-tricks.com/pseudo-element-roundup/

    the client want's it to fit the screen instead of being centered so what I have done is take out the header divs and place them above the main wrapper div and with the footer divs I have placed them after the closing wrapper div tag so the header and footer go all the way across the whole width of the screen so it becomes responsive in a way, is that ok way to do it?
    Yes that's perfectly fine. The only thing I would say though is that you might find, on very wide/high resolution displays, the overall layout could get so stretched-out that it looks a bit awkward. Setting a max-width will give back a bit of control and you can do that on the <body> tag using your preferred width (whenever the content/layout starts to look iffy)

    Code:
    body { max-width:1920px; margin:auto }
    Possible max-widths = 1440px, 1760px, 1920px; You can roughly test how your layout looks on a mammoth widescreen with the help of the browser zoom setting. In Windows you can holding CTRL key and scroll your mouse wheel up and down, OR, press CTRL with the "+" or "-" key.
    Last edited by Beverleyh; 06-15-2015 at 02:07 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #7
    Join Date
    May 2012
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Beverleyh View Post
    Spot on .element::before puts something before/left or behind the element, and .element::after puts something after/right or in front of the element.

    There are loads of fancy things you can do with them - take a look here for ideas: https://css-tricks.com/pseudo-element-roundup/

    Yes that's perfectly fine. The only thing I would say though is that you might find, on very wide/high resolution displays, the overall layout could get so stretched-out that it looks a bit awkward. Setting a max-width will give back a bit of control and you can do that on the <body> tag using your preferred width (whenever the content/layout starts to look iffy)

    Code:
    body { max-width:1920px; margin:auto }
    Possible max-widths = 1440px, 1760px, 1920px; You can roughly test how your layout looks on a mammoth widescreen with the help of the browser zoom setting. In Windows you can holding CTRL key and scroll your mouse wheel up and down, OR, press CTRL with the "+" or "-" key.
    Thank you really appreciate the link and help, will check out that link now

    I just checked it on my 1920 screen and looks ok and looks on my 1280 screen as well

    One thing I wondered if could help me with is the following page, I think it would be better to have the content centered, on that page I got column-left and column-right divs, I know I could use margin: 0 0 0 5%; for example but 5% on the 1280 screen will have a different position when is viewed on the 1920 screen and so on, is there a way to have it centered and remain in the same place across all screen sizes?

  8. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Sorry, I don't really understand what you mean.

    Do you mean that you want to centre the 3 green tabs under the slideshow?

    Try adding #wrapper { text-align: center; }

    And then for each of the tabs, remove the margin and float, and set them to display: inline-block;
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. #9
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    BTW, #footercontainer is causing a horizontal scrollbar, so you might want to remove the width. Divs are block-level elements so they will fill the available width automatically.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #10
    Join Date
    May 2012
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Ahh cool thank you for spotting it and letting me know, i've removed the width from that div now, also it is the column left and column right on the contact page I would like centered, I have done it on my 1280 screen size but on my 1920 screen, it is still over to the left and not central so was seeing if there was a way to center it on both screen sizes?

Similar Threads

  1. Replies: 1
    Last Post: 10-09-2011, 01:16 PM
  2. icon on tab
    By vkbarefoot in forum Looking for such a script or service
    Replies: 2
    Last Post: 07-11-2007, 09:35 PM
  3. Replies: 3
    Last Post: 05-22-2007, 04:25 AM
  4. dhtml tool tip position should be bottom side to the icon always?
    By csmadhav in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 04-04-2007, 11:01 AM
  5. DD Custom Scroller icon position change?
    By Dance10Looks10 in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-27-2005, 06:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •