So I ran into a bit of a problem with the css, I made a div and inside that div is a link that takes over one whole line even thought its not as big as the whole line, whenever I try to add something it pushes it into the next line instead of putting the link on the same line next to each other. How could I possibly make it stick on the same line (already tried display: inline; and display: inline-block;) Here is the code...I know its a mess I'm new to this :D.
Here is the code of my first page:
<html>
<head>
<title>VASMOVIES</title>
<link rel="stylesheet" href="css/vas.css"/>
<script defer src="http://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
</head>
<body>
<header>
<div class="div1">
<h1 title="Home"><a href="home.html"> VASMOVIES </a></h1>
</div>
</header>
<br><br><br><br><br><br><br>
<h1 class="center"> VASMOVIES </h1>
<div class="search-box">
<input class="search-txt" type="text" name="" placeholder="Search for movies">
<a class="search-btn" href="#">
<i class="fas fa-search"></i>
</a>
</div>
<footer>
<button class="button" onclick="darkmode()">Dark/Light mode</button>
<button class="button"><a href="emailpage.html">Contact me</button>
<script>
function darkmode() {
var element = document.body;
element.classList.toggle("dark-mode");
}
</script>
</footer>
</body>
</html>
And here is the CSS:
* {
font-family: Arial, Helvetica, sans-serif;
}
body {
transition: 1s;
padding: 25px;
background-color: #121212;
color: white;
font-size: 25px;
margin: 0;
padding: 0;
}
.button {
background-color: black;
border: none;
border-radius: 50px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button:hover {
transition-duration: 0.5s;
background-color: #333;
}
.dark-mode {
transition: 1s;
background-color: #CAF4F4;
color: black;
}
.center {
color: purple;
text-align: center;
}
.div1 {
width: 70%;
background-color: #333;
border: 2px solid gray;
border-radius: 5px;
margin: auto;
left: 50%;
}
.div2 {
width: 50%;
background-color: #333;
border: 2px solid gray;
border-radius: 5px;
margin: auto;
left: 50%;
color: darkgray;
font-family: Georgia, serif;
line-height: 0.1;
text-align: center;
}
a {
text-decoration: none;
color: purple;
display: inline-block;
}
a:active {
color: purple;
}
footer {
background-color: #333;
text-align: center;
color: #fff;
padding: 20px;
bottom: 0;
width: 100%;
position: fixed;
left: 0px;
}
.search-box {
position: absolute;
top: 50%;
left: 35%;
transfor: translate(-50%, -50%);
background: #333;
height: 40px;
border-radius: 40px;
padding: 10px;
}
.search-box:hover > .search-txt {
}
.search-btn {
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background: #2f3640;
display: flex;
justify-content: center;
align-items: center;
}
.search-txt {
border: none;
background: none;
outline: none;
float: left;
padding: 0;
color: #808080;
font-size: 16px;
transition: 0.4s;
line-height: 40px;
width: 500px;
}
CodePudding user response:
Do you mean this?
<div class="div1">
<h1 title="Home"><a href="home.html"> VASMOVIES </a></h1>
</div>
If so, what do you mean when you say you add something to it?
CodePudding user response:
Is this what you was trying to acheive?
If so you can use the display: inline; CSS class. You have to apply it like so:
<div class="div1">
<h1 title="Home" style="display: inline;">
<a href="home.html" style="display: inline;"> VASMOVIES </a></h1>
<h1 style="display: inline;">Text</h1>
</div>
The CSS does not have to be inline, but I think you understand the example.