I am working on a website. I ran into a slight issue which I haven't been able to fix.
I am trying to make a dropdown menu show up, using 'hover' in CSS, but it is not showing up for some reason.
Here is my HTML code:
<div>
<button class="button button1"> Our Mission</button>
<div class="dropdown">
<button class="button button3">What We Do</button>
<div class="display_things">
<section class="column">
<table>
<tr>
<th>Our donations</th>
</tr>
<tr>
<td><a>Event 1</a></td>
</tr>
<tr>
<td><a>Event 2</a></td>
</tr>
<tr>
<td><a>Event 3</a></td>
</tr>
</table>
</section>
<section class="column">
<table>
<tr>
<th>Our Community Work</th>
</tr>
<tr>
<td><a>Event 1</a></td>
</tr>
<tr>
<td><a>Event 2</a></td>
</tr>
<tr>
<td><a>Event 3</a></td>
</tr>
</table>
</section>
</div>
</div>
<button class="button button4">Donate!</button>
Here is the CSS:
.button3 {
background-color: #00ff9d;
border: none;
color: white;
padding: 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 10px;
border-radius: 20px;
width:400px;
white-space: nowrap;
}
.display_things {
justify-content: space-around;
margin: 10px;
background-color: lawngreen;
display: none;
width: 1100px;
position: absolute;
}
.button3:hover .display_things{
display: block;
}
.button4 {
background-color: #f4740b;
border: none;
color: white;
padding: 15px 170px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 10px;
border-radius: 20px;
width:400px;
}
.button:hover{
background-color: green;
}
Can anyone tell me why exactly the drop-down is not working? I wanted it to be displayed whenever the button is hovered over.
Thank you!
You're using :hover, so your version .button3:hover .display_things { should include either a + or ~, as you're trying to select a sibling.
So you need to change the selector to either;
.button3:hover + .display_things { (for adjacent sibling)
OR
.button3:hover ~ .display_things { (for general sibling, if you are to place anything(s) between the hover and show elements)
Either will work in your code.
Related
whenever I try to add text in footer it already gets positioned in center. I don't know how to fix coz I can't find where is the error. Can anyone help me fix this and also whenever I try to add bootstrap link to my header it affects my drop down css also.
also Im using notepad++ for website
html code
<!DOCTYPE.HTML>
<html>
<head>
<title>
E-Commerce Website
</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="Assignment1.css">
<link rel="stylesheet" type="text/css" href="assi1.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
</head>
<body>
<div class="topnav">
<div class="topnav-right">
<div class="dropdown">
<button class="dropbtn">Cart
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Your Orders
Proceed to checkout
</div>
</div>
</div>
<button class="button" style="vertical-align:middle"><span>Home</span></button></span></button>
<button class="button" style="vertical-align:middle"><span>News</span></button>
<button class="button" style="vertical-align:middle"><span>Sign Up</span></button>
<div class="dropdown">
<button class="dropbtn">More
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Best Sellers
Smartphones
Laptops & Desktops
Electronics
Fashion
Furniture
</div>
</div>
<div class="srch">
<input type="text" placeholder="Search..">
</div>
</div>
</br></br>
<center><img src="banner2.jpg" width="80%" height="65%"></center>
<!--image slider-->
<br><br>
<div class="table1">
<table class="a">
<tr><td colspan="5"><h2>SmartPhones<h2></td></tr>
<tr>
<th><img src="small banner.png" width=250px></th>
<th><img src="phone 1.png" width="70%"></th>
<th><img src="phone 7.jpeg" width="30%"></th>
<th><img src="phone 4.png" width="45%" ></th>
<th><img src="phone 8.png" width="60%"></th>
<th><img src="phone 6.png" width="70%"></th>
</tr>
<tr>
<td></td>
<td><h3>OnePlus Nord 2 5G</h3></td>
<td><h3>Poco M3 5G</h3></td>
<td><h3>Apple iPhone 12 Pro (128GB)</h3></td>
<td><h3>OnePlus 2 Pro</h3></td>
<td><h3>OnePlus 9 Pro 5G</h3></td>
</tr>
<tr>
<td></td>
<td><h4>From ₹29,999</h4></td>
<td><h4>From ₹29,999</h4></td>
<td><h4> ₹1,28,900</h4></td>
<td><h4>From ₹37,999</h4></td>
<td><h4>From ₹37,999</h4></td>
</tr>
</table>
</div>
<br>
<br>
<br>
<div class="table3">
<table class="b">
<tr><td colspan="5"><h2>Laptops<h2></td></tr>
<tr>
<th><img src="small banner.png" width=250px></th>
<th><img src="l1.png" width="80%"></th>
<th><img src="l2.png" width="95%"></th>
<th><img src="L3.png" width="80%" ></th>
<th><img src="l4.png" width="80%"></th>
<th><img src="l5.png" width="80%"></th>
</tr>
<tr>
<td></td>
<td><h3>ROG Strix G17 Advantage Edition G713
</h3></td>
<td><h3>ROG Strix SCAR 17 G733</h3></td>
<td><h3>Razer Blade 15</h3></td>
<td><h3>Legion Y540 - Raven Black</h3></td>
<td><h3>ThinkPad E14 35.56cms-Black</h3></td>
</tr>
<tr>
<td></td>
<td><h4>₹97,999</h4></td>
<td><h4>₹1,29,999</h4></td>
<td><h4> ₹1,30,900</h4></td>
<td><h4>From ₹69,000</h4></td>
<td><h4>From ₹49,999</h4></td>
</tr>
</table>
</div>
<br>
<br>
<br>
<center> <th><img src="banner9.jpg" width="100%" height="80%" ></th> <center>
<br>
<br>
<br>
<div class="table3">
<table class="b">
<tr><td colspan="5"><h2>Laptops<h2></td></tr>
<tr>
<th><img src="small banner.png" width=250px></th>
<th><img src="l1.png" width="80%"></th>
<th><img src="l2.png" width="95%"></th>
<th><img src="L3.png" width="80%" ></th>
<th><img src="l4.png" width="80%"></th>
<th><img src="l5.png" width="80%"></th>
</tr>
<tr>
<td></td>
<td><h3>ROG Strix G17 Advantage Edition G713
</h3></td>
<td><h3>ROG Strix SCAR 17 G733</h3></td>
<td><h3>Razer Blade 15</h3></td>
<td><h3>Legion Y540 - Raven Black</h3></td>
<td><h3>ThinkPad E14 35.56cms-Black</h3></td>
</tr>
<tr>
<td></td>
<td><h4>₹97,999</h4></td>
<td><h4>₹1,29,999</h4></td>
<td><h4> ₹1,30,900</h4></td>
<td><h4>From ₹69,000</h4></td>
<td><h4>From ₹49,999</h4></td>
</tr>
</table>
</div>
<br>
<br>
<br>
<br>
<div class="table2">
<table class="b">
<tr><td colspan="5"><h2>Devices and accessories<h2></td></tr>
<tr>
<th><img src="a1.jpeg" width="55%"></th>
<th><img src="a2.jpeg" width="55%"></th>
<th><img src="a3.jpeg" width="40%"></th>
<th><img src="a4.jpeg" width="50%"></th>
<th><img src="a5.jpeg" width="50%"></th>
</tr>
<tr>
<td><h3>Wired earphones</h3></td>
<td><h3>Bluetooth Headphones</h3></td>
<td><h3>Data cards</h3></td>
<td><h3>Tv streaming devices</h3></td>
<td><h3>Webcams</h3></td>
</tr>
<tr>
<td><h4>From ₹399</h4></td>
<td><h4>From ₹899</h4></td>
<td><h4> Upto 60% off</h4></td>
<td><h4>From ₹2799</h4></td>
<td><h4>From ₹490</h4></td>
</tr>
</table>
</div>
<br>
<br>
<br>
<center><table class="brandtable">
<tr><td><img src = "logo-paypal.png"></td>
<td><img src = "logo-godrej.png"></td>
<td><img src = "logo-oppo.png"></td>
<td><img src = "logo-coca-cola.png"></td>
<td><img src = "logo-philips.png"></td>
</tr>
</table>
</center>
<footer>
<p> hello </p>
</footer>
</body>
</html>
css code
body {
margin: 0;
background-image: linear-gradient(to right, #43cea2, #185a9d);
font-family: 'Poppins', sans-serif;
}
.topnav {
overflow: hidden;
background: orange linear-gradient(#F7971E,#FFD200);
}
.topnav a {
float: left;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 16px;
background: orange linear-gradient(#FFD200);
}
.dropdown {
padding-top:15px;
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
display: inline-block;
border-radius: 4px;
background-color: #ff8c00;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 18px;
padding: 15px;
width: 100px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: black;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.topnav input[type=text] {
float: center;
padding: 6px;
margin-top: 8px;
margin-right: 16px;
width:30%;
border: none;
font-size: 17px;
}
#media screen and (max-width: 600px) {
.topnav a, .topnav input[type=text] {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.topnav input[type=text] {
border: 1px solid #ccc;
}
}
.topnav-right {
float: right;
}
.table a{
table-layout: auto;
}
.table a, h2{
color: #ff4411;
font-size: 25px;
font-family: 'Signika', sans-serif;
padding-bottom: 10px;
}
.table a, h3{
font-family:Roman-55,Helvetica Neue,Helvetica,Arial,sans-serif;
font-size: 19px;
text-align: center;
}
.table a, h4{
font-size: 16px;
color: #388e3c;
padding-top: 8px;
text-align: center;
}
.table1 {
background-image: linear-gradient(#FFAFBD , #ffc3a0);
background-color: white;
}
.table1 td, th {
border: 0px;
width: 200px;
}
.table1{
border-radius: 25px;
margin-left: auto;
margin-right: auto;
padding: 10px;
border: 10px solid orange;
margin: 0;
}
.table2{
border-radius: 25px;
margin-left: auto;
margin-right: auto;
padding: 10px;
border: 10px solid orange;
margin: 0;
}
.table2 {
/* background-image: linear-gradient(#FFAFBD , #ffc3a0); */
background-color: white;
}
.table2 td, th {
border: 0px;
width: 300px;
}
.table3{
border-radius: 25px;
margin-left: auto;
margin-right: auto;
padding: 10px;
border: 10px solid orange;
margin: 0;
background-image: linear-gradient(#3eadcf, #abe9cd);
background-color: white;
}
.table3 td, th {
border: 0px;
width: 300px;
}
/* button hover */
.button {
display: inline-block;
border-radius: 4px;
background-color: #ff8c00;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 18px;
padding: 15px;
width: 100px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.srch{
padding-top:15px;
padding-right:10px;
}
/* brands */
.brandtable{
width:100%;
margin-left: auto;
margin-right: auto;
padding: 10px;
border: 0px;
border-bottom: 2px solid orange;
margin: 0;
background-color:white;
}
/*footer*/
footer{
}
Use table/td/tr tags only if you want to use it for table purpose. For other purpose you can use HTML5 semantic/div tags with CSS3 properties.
Follow HTML5 semantic tag property w3school semantic : w3school semantic tags
Try to use Markup Validation Service to check code quality.
You can see, I took some of part from your code and convert into new style. Solved example codepen.io/ganesh1172/footer-html5
I hope you understand what I want to say. All the best 👍 ✌️.
Because of mistakes in your HTML, chrome somehow wraps your footer in center tag. You can check your HTML here and try to solve problems
https://validator.w3.org/nu/#textarea
There are too many problems with your markup. First thing is stop using center tag, that is outdated now, Use css instead to center the elements.
Your footer is wrapped inside the center tag ( very hard to find but if you see it with the chrome developer tool, you will find that ).
Try to learn modern Html5 and css3 syntax.
Happy learning.
I'm trying to acheive the following (taken from dropbox):
My snippet (in full page):
table {
text-align: left;
position: relative;
border-collapse: collapse;
border: 1px solid black;
}
th, td {
border: 1px solid black;
padding: 1rem !important
}
tr.red th {
background: #FFF;
}
th {
padding: 50px;
background: white;
position: sticky;
top: 111px; /* Don't forget this, required for the stickiness */
}
<table style="margin-top: 150px; margin-left: auto; margin-right: auto;">
<thead>
<tr class="red">
<th></th>
<th>
<div>
Free
</div>
<div>
0 / month
</div>
Sub
</th>
<th>
<div>
Premium
</div>
<div>
99,99€ / month
</div>
Sub
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div style="display: flex; align-items: center; width: 100%;">
<span>
<div style="display: inline-block; width: 22px; height: 22px; margin-left: -11px;">
<button style="width: 22px; height: 22px; display: block; background: transparent;" aria-label="More info"></button>
</div>
</span>
<span style="margin-left: 15px; display: flex;">Storage</span>
</div>
</td>
<td>2 Go</td>
<td>15 To</td>
</tr>
</tbody>
</table>
Here you go...
The easiest way to achieve this circle with the letter "i" inside is to use Font Awesome icon. Move the icon to the left by setting margin-left: -25px;. You have to set z-index: 100; (the value is not important, it could be 1) to push the icon in front of everything else. It's necessary to set position: absolute;, otherwise the z-index won't work. Also, set background-color: white; so that the line of the table isn't visible in the background of the icon (try to remove the background-color to see what I'm talking about).
table {
text-align: left;
position: relative;
border-collapse: collapse;
border: 1px solid black;
}
th,
td {
border: 1px solid black;
padding: 1rem !important;
}
tr.red th {
background: #FFF;
}
th {
padding: 50px;
background: white;
position: sticky;
top: 111px;
height: 250px;
/* Don't forget this, required for the stickiness */
}
.fa-info-circle {
position: absolute;
background-color: white;
font-size: 20px;
margin-top: -7%;
margin-left: -24%;
z-index: 100;
}
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
<script src='https://use.fontawesome.com/releases/v5.15.3/js/all.js' data-auto-replace-svg='nest'></script>
</head>
<body>
<table style='margin-top: 150px; margin-left: auto; margin-right: auto;'>
<thead>
<tr class='red'>
<th> <i class='fas fa-info-circle'></i> </th>
<th>
<div>
Free
</div>
<div>
0 / month
</div>
<a href='#' class='pricing-plans__cta button button--primary'>Sub</a>
</th>
<th>
<div>
Premium
</div>
<div>
99,99€ / month
</div>
<a href='#' class='pricing-plans__cta button button--primary'>Sub</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div style='display: flex; align-items: center; width: 100%;'>
<span>
<div style='display: inline-block; width: 22px; height: 22px; margin-left: -11px;'>
<button style='width: 22px; height: 22px; display: block; background: transparent;' aria-label='More info'></button>
</div>
</span>
<span style='margin-left: 15px; display: flex;'>Storage</span>
</div>
</td>
<td>2 Go</td>
<td>15 To</td>
</tr>
</tbody>
</table>
</body>
</html>
You can simply do that by setting the position attribute of the button to absolute and then use it to position according to its ancestor
Here is an MDN Link to know more about this
Add this CSS code to your file and it will work
button{
position: absolute;
left: -12px;
}
I added <span class="information">i</span> into your 1st td and then added the CSS as below:
/* ADDED */
td::first-child{
position:relative;
}
.information{
position:absolute;
left: -12px;
width: 20px;
height: 20px;
border:1px solid black;
border-radius: 100%;
text-align: center;
background: white;
}
DEMO
table {
text-align: left;
position: relative;
border-collapse: collapse;
border: 1px solid black;
}
th, td {
border: 1px solid black;
padding: 1rem !important
}
tr.red th {
background: #FFF;
}
th {
padding: 50px;
background: white;
position: sticky;
top: 111px; /* Don't forget this, required for the stickiness */
}
/* ADDED */
td::first-child{
position:relative;
}
.information{
position:absolute;
left: -12px;
width: 20px;
height: 20px;
border:1px solid black;
border-radius: 100%;
text-align: center;
background: white;
}
<table style="margin-top: 150px; margin-left: auto; margin-right: auto;">
<thead>
<tr class="red">
<th></th>
<th>
<div>
Free
</div>
<div>
0 / month
</div>
Sub
</th>
<th>
<div>
Premium
</div>
<div>
99,99€ / month
</div>
Sub
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="information">i</span>
<div style="display: flex; align-items: center; width: 100%;">
<span>
<div style="display: inline-block; width: 22px; height: 22px; margin-left: -11px;">
<button style="width: 22px; height: 22px; display: block; background: transparent;" aria-label="More info"></button>
</div>
</span>
<span style="margin-left: 15px; display: flex;">Storage</span>
</div>
</td>
<td>2 Go</td>
<td>15 To</td>
</tr>
</tbody>
</table>
This will work for u
* {
margin: 0px;
padding: 0px;
}
td {
position: relative;
padding: 40px;
border: 1px solid;
margin: 0px;
font-family: 'arial';
}
td a {
font-family: initial;
position: absolute;
font-size: 22px;
font-style: italic;
text-decoration: none;
left: -5%;
top: 38%;
height: 25px;
width: 25px;
text-align: center;
border-radius: 50%;
color: black;
background-color: white;
border: 1px solid;
}
table {
margin: 50px;
border-collapse: collapse;
}
<table>
<tr>
<td>i Espace de stockage</td>
<td>2 Go</td>
<td>2 To (2000 go)</td>
</tr>
<tr>
<td>i Espace de stockage</td>
<td>2 Go</td>
<td>2 To (2000 go)</td>
</tr>
<tr>
<td>i Espace de stockage</td>
<td>2 Go</td>
<td>2 To (2000 go)</td>
</tr>
</table>
I am facing an issue with a button set in a table cell which covers two rows. it does not fill the second row. how can i make this button fill both rows? I have tried to set height in the style of the button as well as on the table cell itself without success. Please see my code is below:
1) the css style of the button:
.button {
padding: 5px 15px;
font-size: 1.1em;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 1px;
box-shadow: 0 2px #999;
width: 100%;
vertical-align: middle;
}
And 2) my html table below:
<tr>
<td rowspan="2">
<button href="#0" class="button" id="cancel_order">Aκύρωση</button>
</td>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Εκτύπωση</button>
</td>
<td rowspan="2">
<button class="button">Παραγγελία</button>
</td>
</tr>
<tr>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Απόδειξη</button>
</td>
</tr>
In my opinion you should use css3 flexbox to achieve this as shown below:
.btn-holder {
display: flex;
}
.btn-holder .btn-holder {
flex-direction: column;
}
.button {
margin: 0 5px 5px 0;
padding: 5px 15px;
font-size: 1.1em;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 1px;
box-shadow: 0 2px #999;
}
<div class="btn-holder">
<button class="button" id="cancel_order">Aκύρωση</button>
<div class="btn-holder">
<button class="button">Εκτύπωση</button>
<button class="button">Παραγγελία</button>
</div>
<button class="button">Απόδειξη</button>
</div>
https://jsfiddle.net/k5wefqz5/1/
Is this your expected result ?
You miss <table> tag to complete your code.
Add this:
button {height:100%; }
Wrap table elements inside a <table> in order to get <td> and <tr> to behave as expected.
SNIPPET
table {
border: 1px solid red;
}
td {
border: 1px solid black;
}
button {
height: 100%;
}
<table>
<tr>
<td rowspan="2">
<button href="#0" class="button" id="cancel_order">Aκύρωση</button>
</td>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Εκτύπωση</button>
</td>
<td rowspan="2">
<button class="button">Παραγγελία</button>
</td>
</tr>
<tr>
<td style="padding-right:5px; padding-left:5px;" colspan="2">
<button class="button">Απόδειξη</button>
</td>
</tr>
</table>
I want to centre align a number of tables next to each other at the top in the middle of a div. Underneath these tables I want to have a list of vertical buttons left aligned. I have tried many different techniques but none of which seem to work. Please could someone help?
Current Fiddle Example:
https://jsfiddle.net/Jaron787/gg30jgh5/
CSS
.TSS {
font-family: Verdana, Geneva, sans-serif;
font-size: 10.6px;
font-style: normal;
text-decoration: none;
float: left;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
border: 1px solid black;
}
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
HTML
<div id="lse" class="display">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
<input type="submit" class="button button1" name="submitButton" value="Button 1">
<input type="submit" class="button button1" name="submitButton" value="Button 2">
<input type="submit" class="button button1" name="submitButton" value="Button 3">
<input type="submit" class="button button1" name="submitButton" value="Button 4">
</div>
Probably just create a wrapper around the tables.
<div id="centertbl">
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 1</b></td>
</tr>
</table>
<table id="tblData" class="TSS">
<tr>
<td align="center" colspan="4"><b>Table 2</b></td>
</tr>
</table>
Then apply the text-align to center.
#centertbl { text-align: center;}
That will center the tables in middle. Removed the margin: 0 auto; from the class .TSS.
Change the button css code from display: inline-block; to display: block;
jsFiddle : https://jsfiddle.net/gg30jgh5/6/
I think you need this type of css:
please check updeted fiddle link:
some changes in your html structure.table is one div and button is another sepreate div.
https://jsfiddle.net/gg30jgh5/9/
Set both tables inside a div and set margin-left:50% for this div
Set all buttons inside a div and set clear:both for this div.
I create the following HTML page and I would align the two DIV elements (the ones with lista and scheda id, contained within parent div) to the same position, at the top of the page. Here is my code:
#tabella1,
#tabella1 td {
border: solid 1px;
}
th {
border: solid 1px;
font-style: bold;
background-color: white;
}
#tabella1 tr:nth-child(odd) {
background-color: gray;
}
#tabella1 tr:nth-child(even) {
background-color: lightgray;
}
#tabella1 tr:nth-child(n):not(:nth-child(1)):hover {
background-color: blue;
color: yellow;
cursor: pointer;
}
.titolo {
text-align: center;
font-weight: bold;
}
#lista {
display: inline-block;
margin: 30px;
position: relative;
top: 0px;
}
button {
width: 60px;
height: 20px;
}
form {
display: inline-block;
}
#msg {
font-weight: bold;
}
#scheda {
display: inline-block;
position: relative;
top: 0px;
text-align: center;
}
#tabella2 td:nth-child(even) {
border: solid 1px;
}
.cellaVuota {
width: 140px;
}
<div id="carica">
<form method="post" action="carica2.php">
<label for "n">Inserisci nome:
<input type="text" id="n" name="nome" size="10" />
</label>
<button type="submit">Invia</button>
</form>
<form method="post" action="carica2.php">
<button type="submit" name="logout">Logout</button>
</form>
</div>
<div id="parent">
<div id="lista">
<table id="tabella1">
<tr>
<th>Modello</th>
<th>27.5</th>
<th>29</th>
</tr>
<tr>
<td>Riga 1</td>
<td>Riga 2</td>
<td>Riga 3</td>
</tr>
</table>
<p class="titolo">Bici Mountain Bike</p>
</div>
<div id="scheda">
<p class="titolo">Bici selezionata</p>
<table id="tabella2">
<tr>
<td>Modello</td>
<td class="cellaVuota"></td>
</tr>
<tr>
<td>Misura 27.5</td>
<td class="cellaVuota"></td>
</tr>
<tr>
<td>Misura 29</td>
<td class="cellaVuota"></td>
</tr>
</table>
</div>
</div>
I searched and searched here before post this question (see position and ~top` properties in the CSS code), but I do not figure out how to reach my purpose.
Just add vertical-align: top; to both divs.
You can also remove position: relative; and top: 0; properties