Is it possible to set the equivalent of a src attribute of an img tag in CSS?

后端 未结 25 2764
借酒劲吻你
借酒劲吻你 2020-11-22 09:30

Is it possible to set the src attribute value in CSS? At present, what I am doing is:


25条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 10:15

    HTMl Code:

    
    
         
             
         
         
    
                
    
                    

    Text that is not important

    Css Code:

    span {
         display: none;
    }
    h1 id or class {
         height: of pic;
         width: of pic;
    /* Only flaw (so far) read bottom */
         background-image:url(/* "image destination" */);
    }
    h1 id or class:hover {
    /* Now the awesome part */
         background-image:url(/* 'new background!!!' */);
    }
    

    I've been studying html after school for a few days, and wanted to know how to do this. Found out the background and then put 2 and 2 together. This works 100% I checked, if not make sure you fill in necessary things!!! We need to specify height, because without it there would be nothing!!! I'll leave this basic shell you can add-on.

    Example:

     
     
         
             
         
         
                
                    

    Text that is not important

    span { display: none; } h1 { height: 100px; width: 100px; background-image:url("http://linuxlog.org/wp-content/uploads/2011/01/Ubuntu-Desktop-@-2011-01-11-191526-300x225.png"); } h1:hover { height: 300px; width: 300px; background-image:url("http://cdn.css-tricks.com/images/ads/wufoo-600x600-red.png"); }

    P.S. Yes I am a Linux user ;)

提交回复
热议问题