Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Posts posted by jeffman

  1. I think you misunderstand. What you HAVE is not the default. Something is wrong. Something in your code is overriding the default behavior somehow. You shouldn't have to ADD anything at all. That's why someone has to look at your code, to find out what's wrong. (It can't possibly be only the little bit of CSS you posted above.) A link to a live site would be best.

  2. I think the biggest issue is that you are using some unadvisable techniques. 1. Don't use the old transitional doctype. Step up to HTML5. It's the best way to ensure consistency. 2. Don't use the old marquee element. Users really hate it. If you MUST have one, try using a jQuery plugin like this. 3. Don't use absolute positioning. Try using the CSS float property instead.

  3. @mehdikhalifeh It cannot be done. The site owners post the content for free, so we do not have to pay for it. In exchange, they want us to view their advertisements. That is how they earn money.

  4. Try running this code.

    function loop(i) {   i++;   loop(i);}loop(0);

    You will not be able to interact with the document or execute any other code until an error dialog pops up telling you you're stuck in an infinite loop.

  5. Two possibilities. 1. Test for a condition that will tell the function to execute or not. A basic pattern is this:

    function runIt () {   // some code   if (x == 5) {	  return;   } else {	  runIt();   }}

    2. Use a timer, possible with a conditional as I described above.

  6. It always helps to show code. If you means this: CSS

    div {   background-image: url('pic.jpg');}

    and this: HTML

    <div><img src="pic.jpg"></div>

    The only important difference is the layout and appearance. One is not more efficient than the other. The image needs to be requested and downloaded in both cases. After that, the browser will store the image in its cache so it does not need to be downloaded again. If there are internal differences, they are small. The only real consideration is the size of the image, and that does not change.

    • Like 1
  7. OK, but: dsonesuk is right about those spaces. I still don't like putting blocks inside line-level elements, even if it does validate. What I shouldn't have done was recommend something I wouldn't really do. I tried to accommodate the original code, and the result is off. What I'd do myself is more like this:

    #navigation{  width: 800px;  background: #5C4033;}#navigation ul{  margin: 0;  padding: 0;  height: 30px;  line-height: 30px;}#navigation li{  display: block;  float: left;  list-style-type: none;}#navigation a{  display: block;  color: #fff;  text-decoration: none;  border-right: 1px solid #fff;  padding: 0px 10px;  cursor: pointer;}#navigation a:hover{  background-color: #000;}

    Notice that I'm nesting blocks inside blocks now. The float eliminates the space dsonesuk mentioned. I set some heights, too. That makes sure the enclosing div HAS a height, since we're back to floating now. The line height makes sure the text is vertically centered. I personally like to control my elements' dimensions anyway; other designers keep things relative to everything else. It's a choice.

  8. Whoa. Unless the book has other problems, that surprises me. In 2013, you really shouldn't put a block-level element inside an inline element. The document will validate, because the validator doesn't check that. But on it's face it seems really wrong. Try this and see if it works in your project:

    #navigation{width:800px;background: #5C4033;}#navigation ul{margin:0;padding:0;}#navigation ul li{display:inline-block;list-style-type:none;}#navigation ul li a{display:inline-block;color:#fff;text-decoration:none;border-right:1px solid #fff;padding:5px 10px;}#navigation li a:hover{background:#000;}

×
×
  • Create New...