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

Thread: change the location of a div for responsive

  1. #1
    Join Date
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default change the location of a div for responsive

    i have a div for a cart logo and total price that sits in the top corner of the screen
    HTML Code:
    #layout #main #cart {
    	background-color: #000;
    	height: 30px;
    	width: 20%;
    	padding: 10px;
    	position: fixed;
        top: 0em;
        right: 0em;
    }

    PHP Code:
    <div class="cartText" id="cart"><a href="../SS16/cart.php"><img src="../images/trolley.png" width="25" height="25"></a> <?php echo $XCart_numItems sizeof(${$XCName}["contents"][0]) ?>  Item(s) | &pound; <?php echo $XCart_sumTotal?></div>
    what i want to do is when the website is scaled down for this box to site full width across the bottom of the screen

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

    Default

    Change width to 'auto' (or 100%) to make it span the full width.

    Change vertical position to bottom:0; (remove 'top')

    Also check your syntax because CSS selectors should be comma separated (#layout, #main, #cart {...} )

    If you need more help, please post a link to the page.
    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
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    Change width to 'auto' (or 100%) to make it span the full width.

    Change vertical position to bottom:0; (remove 'top')

    Also check your syntax because CSS selectors should be comma separated (#layout, #main, #cart {...} )

    If you need more help, please post a link to the page.
    sorry i wanted to keep as it is on larger screen just to change location when on mobile devices

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

    Default

    You'll need to modify the CSS inside your media queries. I don't know which way you're working - mobile first or desktop first - but you should be able to work out which of your media queries hold the 'mobile' stuff from the behaviour of other elements. You can also investigate the elements in your developer toolbar for further pointers - F12 in most browsers.

    Like I said before though, if you need more help, please post a link to the page, otherwise all we can give you are general suggestions.
    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
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    You'll need to modify the CSS inside your media queries. I don't know which way you're working - mobile first or desktop first - but you should be able to work out which of your media queries hold the 'mobile' stuff from the behaviour of other elements. You can also investigate the elements in your developer toolbar for further pointers - F12 in most browsers.

    Like I said before though, if you need more help, please post a link to the page, otherwise all we can give you are general suggestions.
    ok here is a sample http://www.jonfortis.co.uk/movediv/indexSS16.php

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

    Default

    Going back to what I said earlier, you need to put your CSS modifications/overrides inside your media queries for mobile sizes - like you're already doing for the side menu, but for this div.
    Code:
    #cart {
    width:auto; /* or 100% */
    bottom:0;
    top:auto; /* set this line back to default */
    }
    You shouldn't need other over-specific CSS selectors either (#layout #main #cart) - an id is as specific as it gets (barring inline styles).
    Last edited by Beverleyh; 01-29-2016 at 03:26 PM. Reason: typo
    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
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    Going back to what I said earlier, you need to put your CSS modifications/overrides inside your media queries for mobile sizes - like you're already doing for the side menu, but for this div.
    Code:
    #cart {
    width:auto; /* or 100% */
    bottom:0;
    top:auto; /* set this line back to default */
    }
    You shouldn't need other over-specific CSS selectors either (#layout #main #cart) - an id is as specific as it gets (barring inline styles).
    i added that to side-menu.css but it didnt appear to work ?

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

    Default

    I can't check anything because I'm on mobile but I would say it's because of specificity; If you've kept the chain of 3 id selectors in the desktop stylesheet/media queries, but only used #cart in the mobile CSS, the desktop definitions with greater specificity will always be overriding the lower specificity #cart selector. What I meant before is that you shouldn't need the over-specific selectors *anywhere*. Try changing all occurrences to #cart so that specificity is the same wherever it's mentioned. If that doesn't work, maybe all the selectors *are* needed (due to overrides elsewhere in the cascade) so change them all to #layout #main #cart

    TIP : Whenever you're up again CSS angst like this, you should head for the developer toolbar - that's F12 in most browsers. If you're unsure how to use the tool bar, look for a tutorial on Google that shows you how to inspect an element and live-edit CSS in the style pane. It's pretty straight-forward though so playing around with it sans-tutorial will probably be enough, with a bit of trial and error. Learning how to use the developer toolbar will really help you troubleshoot CSS issues.
    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
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    I can't check anything because I'm on mobile but I would say it's because of specificity; If you've kept the chain of 3 id selectors in the desktop stylesheet/media queries, but only used #cart in the mobile CSS, the desktop definitions with greater specificity will always be overriding the lower specificity #cart selector. What I meant before is that you shouldn't need the over-specific selectors *anywhere*. Try changing all occurrences to #cart so that specificity is the same wherever it's mentioned. If that doesn't work, maybe all the selectors *are* needed (due to overrides elsewhere in the cascade) so change them all to #layout #main #cart

    TIP : Whenever you're up again CSS angst like this, you should head for the developer toolbar - that's F12 in most browsers. If you're unsure how to use the tool bar, look for a tutorial on Google that shows you how to inspect an element and live-edit CSS in the style pane. It's pretty straight-forward though so playing around with it sans-tutorial will probably be enough, with a bit of trial and error. Learning how to use the developer toolbar will really help you troubleshoot CSS issues.
    would it be best to start again and give the div a class <div class="cart"> then make all the css .cart rather than #cart

  10. #10
    Join Date
    Nov 2011
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jonnyfreak View Post
    would it be best to start again and give the div a class <div class="cart"> then make all the css .cart rather than #cart
    i have just tried that and that hasnt worked.

Similar Threads

  1. Change default download location
    By round in forum PHP
    Replies: 2
    Last Post: 06-25-2012, 10:56 AM
  2. 'go' button location change
    By MonteChristo in forum JavaScript
    Replies: 1
    Last Post: 02-14-2008, 11:01 PM
  3. slashdot menu _ Change it's location!
    By daobuocchanmay in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 09-16-2006, 05:17 PM
  4. Marquee - Location change
    By brycol in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 12-02-2005, 10:41 AM
  5. Marquee - Location change
    By brycol in forum JavaScript
    Replies: 3
    Last Post: 12-02-2005, 10:30 AM

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
  •