I'm making a Button menu for a project for a web development course. I'm using <div>
s to create the clickable menu that changes shades when hovering. I wanted it so that the user can't select the text (since it's a button). I'm using a flex layout scheme (at least I think I'm doing it correctly). I have the following code but it's behaving differently in different browsers. I included a screen cap link below that is from left to right Chrome, Firefox, and Safari.
Here's the code for the menubar:
<style type="text/css">
.button {
margin: 0;
padding: 5px;
background-color: #CCCCCC;
height: 100%;
font-family: helvetica, sans-serif;
display: flex;
align-items: center;
user-select: none;
}
.buttonDivider {
border-left: gray 1px solid;
height: 100%;
}
.button:hover{
background-color: gray;
cursor: pointer;
}
#buttonBar {
display: flex;
border: gray 1px solid;
border-radius: 5px;
overflow: hidden;
margin: 0 auto;
align-items: center;
user-select: none;
}
#titleBar {
display: flex;
width: 100%;
height : 40px;
padding: 5px;
background-color: #CCCCCC;
user-select: none;
}
#titleText {
display: flex;
align-items: center;
font-family: helvetica, sans-serif;
font-size: 25px;
font-weight: bold;
}
body{
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="titleBar">
<span id="titleText">CodePlayer</span>
<div id="buttonBar">
<div id="buttonHTML" class="button">HTML</div>
<div class="buttonDivider"></div>
<div id="buttonCSS" class="button" style="user-select:none">CSS</div>
<div class="buttonDivider"></div>
<div id="buttonJS" class="button">JavaScript</div>
<div class="buttonDivider"></div>
<div id="buttonOutput" class="button">Output</div>
</div>
</div>
But as you can see from the video, the behavior is quite different in 3 browsers (all updated to the latest version as of this post, Chrome 56, Firefox 51, and Safari 10.0.3). Chrome is the closest. It prevents the user from selecting the text and on hover fills the entire area. The only weird thing is when you click and drag while it doesn't select the text, the cursor changes to the highlight cursor. Firefox is next best as it shades the entire button on hover, but doesn't obey user-select: none
and as you can see, Safari neither fills in the entire box as the other two do on hover but also allows full selection.
Screencap here: Video of different behaviors in different browsers. From Left to Right: Chrome, FireFox, Safari
Am I doing something non-standard? Or are these bugs? and if so, is there a way to make them all behave properly? Thanks!