Use margins or absolute positioning?


No it isn't. It is inside -- it is not on top. There's a big difference. Previously you were using negative margins to drag an element back on top of something else. In the latest example there is nothing to drag it on top of as it is just inside.


I don't know this is the CSS forum!

That's a completely different question and will require a JS answer.


Do you know javascript?


How would I make the javascript not specific, and what does that even mean?


I just meant that when you moved the div the js didn't work so obviously the js expected it to be where it was.


If I showed you this, would you be able to say if it's correct or not?

  (function iife() {
    "use strict";
    var playButton = document.querySelector(".playButton");
    playButton.addEventListener("click", firstClick);
		function firstClick() {
      var button = document.querySelector(".playButton");
      var player = document.querySelector("#player");
      document.querySelector('.playButton .initial').style.display = 'none';
      playButton.addEventListener("click", playButtonClickHandler);
      document.querySelector(".playButton .play").style.display = "inline-block";
      document.querySelector(".playButton .pause").style.display = "none";
    function playButtonClickHandler() {
      player.volume = 1.0;
      if (player.paused) {
        document.querySelector(".playButton .play").style.display = "none";
        document.querySelector(".playButton .pause").style.display = "inline-block";;
      } else {
        document.querySelector(".playButton .play").style.display = "inline-block";
        document.querySelector(".playButton .pause").style.display = "none";



To me it seems like a lot of code to do one thing. Maybe less code could be used, I'm not sure.


Looks ok to me but I'm sure Paul W or one of the other JS gurus could help streamline it.


Exactly. We'll be working on this some more next week. You helped a lot and thank you.


What exactly do you mean by auto center, I don't get that?

Can you show me what you mean here?


Add this:

  .pause3 {
  display: block;
  margin:16px auto 0;

You would then need to change the JS to block instead of inline-block here.

  if (player.paused) { = "none"; = "block";;
      } else { = "block"; = "none";

The absolute method would also be fine in this case except it is more code but benefits from not having to work out the top margin as absolute elements auto centre vertically as well as horizontally for fixed width and height elements.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.