Tristan T Tristan T - 2 months ago 5
CSS Question

why is my icon not to the right side

I have an icon which should be floating right. But there is always a lot of space between the right side and the icon. I do not why this is the case. But it should be 5px left from the right side. Maybe it has something to do with the fact that I use the google icons like you can see in my code. How can I get the icon completely to the right?



/* Initial body */
body {
left: 0;
margin-bottom: 100px;
overflow: hidden;
position: relative;
}


/* Basic styling */

.header {
background-color: green;
height: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.icon-menu {
color: #fff;
cursor: pointer;
font-family: 'Open Sans', sans-serif;
font-size: 16px;
padding-bottom: 10px;
padding-left: 25px;
padding-top: 10px;
text-decoration: none;
text-transform: uppercase;
}

.icon-menu i {
margin-top: 0px;
}

.button-group {
margin-bottom: 20px;
}

.counter {
display: inline;
margin-top: 0;
margin-bottom: 0;
margin-right: 10px;
}

.material-icons.md-36 {
font-size: 36px;
padding-right: 5px;
color: white;
}

.icons-right {
float: right;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 100px;
align-text: center;
}

.nav li {
display: inline-block;
color: red;
}

html {
position: relative;
min-height: 100%;
}

<!doctype html>
<html lan="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="A page about me">
<meta name="keywords" content="web developer, projects">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>title</title>

<!-- google icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- the icon font -->
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">

</head>
<body>

<div class="body">
<div class="header">

<div class="icon-menu">
<a href="/logout"><i class="material-icons md-36 icons-right">lock outline</i></a>

<span class="icons-right">person</span>
<div class="click"><i class="material-icons md-36">menu</i></div>

</div>
</div>
</div>

</body>
</html>




Answer

Here it goes. Just add a width to the lock icon.

body {
  left: 0;
  margin-bottom: 100px;
  overflow: hidden;
  position: relative;
}


/* Basic styling */

.header {
  background-color: green;
  height: 100%;
  -webkit-background-size: cover;
     -moz-background-size: cover;
       -o-background-size: cover;
          background-size: cover;
}

.icon-menu {
  color: #fff;
  cursor: pointer;
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  padding-bottom: 10px;
  padding-left: 25px;
  padding-top: 10px;
  text-decoration: none;
  text-transform: uppercase;
}

.icon-menu i {
  margin-top: 0px;  
  margin-right: 5px;
}

.button-group {
  margin-bottom: 20px;
}

.counter {
  display: inline;
  margin-top: 0;
  margin-bottom: 0;
  margin-right: 10px;
}

.material-icons.md-36 {
  font-size: 36px;
  padding-right: 5px;
  color: white;
}

.icons-right {
  float: right;
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    align-text: center;
}

.nav li {
  display: inline-block;
  color: red;
}

html {
    position: relative;
    min-height: 100%;
}

.lock-icon{
  width: 10%;
}
<!doctype html>
<html lan="en">
<head>
    <meta charset="UTF-8">
    <meta name="description" content="A page about me">
    <meta name="keywords" content="web developer, projects">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>title</title>

    <!-- google icons -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <!-- the icon font -->
    <link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">

</head>
<body>

    <div class="body">
        <div class="header">

            <div class="icon-menu">
                    <a href="/logout"><i class="material-icons md-36 icons-right lock-icon">lock outline</i></a>

                <span class="icons-right">person</span>
                <div class="click"><i class="material-icons md-36">menu</i></div>

            </div>
        </div>
    </div>

</body>
</html>

Comments