Home > OS >  Overlap Home Image Button over a colorbar
Overlap Home Image Button over a colorbar

Time:12-26

First of all, sorry for my bad English, hope you understand me. Second, I started programing yesterday, wathed lots of tutorials and didn't found anything, probably I am just dumb.

Just begun a new html project, I started with a colored bar for the top of the website, then linked an image to the main html project, something like Home navigation bar image idk. Now the problem is, I want to overlap the already linked to main html to colored bar (https://i.stack.imgur.com/iVqm3.png)

Bluebar CSS code:

.upperblue {
    width: 100%;
    background-color: rgb(71, 103, 245);
    height: 100px;
    position: relative;
}

Image HTML and CSS

<p id="homeimage">
    <a href="/index.html">
        <img `src="https://lh3.googleusercontent.com/EiXgCES3j3b98a6ADBoU37yzcAO1shECNmOzbCZn2HYcUBPW4xiFmCHsXCy-A`mWGTn5ySEU3U-Rpq2H_NrXjjuSg-Qrr3m74XSVF0y9VD6ayXRy2zYaTVqONCjlneaMfsb352Z0S=w2400" height="185"
            width="426">
    </a>
</p>

CodePudding user response:

Welcome to our community ! Also keep in mind to maintain the objective to your question , giving to us reproducible examples always you could !

I understand you a little for having started to learn now, I'm learning too and I don't know the name of everything..

CSS SELECTORS // HTML TUTORIAL

Lets go to the code, i made a example here, i import some fonts , a bunch of CSS selectors . Start studing , ctrl shift i on chrome was a good tool for you test it all !!!

<!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>
    <!-- IMPORTING GOOGLE MATERIAL FONT ICONS (https://fonts.google.com/icons) -->
    <!--
        How to use it :
        Place the .material-symbols-outlined class in some element that have text (div,span,p,li,table,footer,header,etc..)
        I think that it only dont work like inputs, textarea elements
        Found some icon : [eg: https://fonts.google.com/icons?icon.query=menu]
        Click and copy the example that show right in the page . 
        example :
        <span >menu</span>
    -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material Symbols Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
    <!-- IMPORTING POPPINS FONT FROM GOOGLE FONTS (https://fonts.google.com/) -->
    <!--
        How to use it :
        On the google page , well on the up-right side on the page have an button : 'View selected families'
        (Its a icon actually, you will not see the text XD)
        Click there and you will see how to use each font
    -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&display=swap" rel="stylesheet">
<style>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    list-style: none;
    outline: none;
    font-family: 'system-ui', 'sans-serif';
    font-weight: 300;
    transition: .3s linear 0s all;
}
h1 , h2 ,h3 , h4, h5 {
    font-weight: 500;
}
h1 {
    font-size: 2rem;
}
h2 {
    font-size: 1.8rem;
}
h3 {
    font-size: 1.6rem;
}
h4 {
    font-size: 1.4rem;
}
h5 {
    font-size: 1.2rem;
}
h6 {
    font-size: 1.1rem;
}
body {
    margin: 0;
}
main {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
}
/* NOTE THAT HERE WE USE 2REM IN THE SIZE OF ASIDE ICONS , BECAUSE IS THEIR SIZE ON .header-icon ;D */
main > header {
    flex: 0 0 50px;
    display: grid;
    grid-template-columns: 2rem auto 2rem;
    justify-items: center;
    align-items: center;
    background: linear-gradient(45deg, #e7e7e7, #b9b9b9);
    border-bottom: 1px solid #b5b5b5;
}
main > header > div:nth-child(1) {
    margin: 0;
}
main > header > div:nth-child(2) {
    margin: 0;
}
main > header > div:nth-child(3) {
    margin: 0;
}
main > section {
    flex: 1 0 auto;
    padding: 10px;
    background: #f1f1f1;
}
main > section > div:nth-child(1) {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    padding: 10px;
    background: white;
}
main > section > div:nth-child(1) > p {
    margin-top: 10px;
}
main > footer {
    flex: 0 0 10vmin;
    display: grid;
    grid-template-columns: auto auto auto;
    justify-items: center;
    border-top: 1px solid #ffffff82;
    background: #e7e7e7;
}
main > footer > div:nth-child(1) {
    margin: 0;
}
main > footer > div:nth-child(2) {
    margin: 0;
}
main > footer > div:nth-child(3) {
    margin: 0;
}
/* SEE THAT , WE CAN TURN OUR ICON BIGGER SETTING A FONT-SIZE PROPERTY !! ALSO OTHER OPTIONS*/
.header-icon {
    font-size: 2rem;
}
/* ALSO NOTE THE CSS SELECTORS IM USING ...*/
a.normal {
    color: black;
    text-shadow: 0px 0px 1px black;
    transition: .1s linear 0s text-shadow;
}
a.normal:hover {
    text-shadow: 0px 0px 2px black;
}
a.button {
    display: block;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    text-align: center;
    text-shadow: 1px 1px grey;
    border: 1px solid gray;
    background: #c1c1c1;
    padding: 4px 14px;
    transform: translate(0px, 0px);
    transition: .1s linear 0s all;
}
a.button:hover {
    transform: translate(1px, -1px);
    box-shadow: 0px 0px 3px -1px #00000069;
}
button.sucess {
    border-radius: 6px;
    background: green;
    color: white;
    padding: 2px 10px;
    border: 0;
}
</style>
</head>
<body>
    <main>
        <header>
            <!-- Using google materials icons font with a custom class !! the default class need to be here !!-->
            <div><span >menu</span></div>
            <div><h3>LOGO</h3></div>
            <div><span >toggle_on</span></div>
        </header>
        <section>
            <div>
                <h5>Main content</h5>
                <p>
                    Lorem ipsum dolor sit amet. Est internos galisum ut adipisci voluptas qui ipsum quisquam aut dicta assumenda ut iste velit sit quia quasi id sequi fugiat. Et autem veniam eum alias optio et quas tenetur aut aperiam dolorem est soluta laboriosam non cupiditate officiis qui neque consequatur. Est ipsam numquam sit nobis iure quo assumenda quidem ut voluptatem accusamus rem consequatur nesciunt eum deserunt accusamus ad eaque explicabo. Hic quam facilis et dolorum galisum ut dolorum aliquid ad dolorem sapiente in aspernatur nemo sed veritatis maxime non dolorem quisquam.

                    A nemo voluptas a repellat iste ut harum dolor aut neque dolorum nam voluptatibus amet quo repellat autem et quasi nemo. Vel temporibus adipisci nam nesciunt quidem aut voluptas placeat in accusantium sunt ut laborum illum a esse quia aut doloribus molestiae. Ut sint nemo non odit autem ea optio repudiandae et sequi nostrum.

                    Aut culpa cumque qui repellendus earum aut dolores labore et velit ullam eum ratione culpa ut nemo repellat in dolorum eius. Et cupiditate maxime eos officiis animi eos architecto quam aut ipsa inventore. Ad quos sint ex cumque quis eum officiis harum qui culpa soluta eos optio omnis ut voluptatem accusamus aut ratione fugit. Et inventore vero ab eligendi debitis sit tempore dicta nam voluptatem nostrum.
                </p>
                <a href="#" >Link</a>
                <a href="#" >Link</a>
                <button >Button</button>
                <textarea name="" id="" cols="30" rows="10"></textarea>
                <input type="checkbox" name="" id="myCheckbox"><label for="myCheckbox"></label>
                <input type="date" name="" id="">
                <input type="file" name="" id="">
                <input type="number" name="" id="">
                <input type="password" name="" id="">
                <input type="search" name="" id="">
                <input type="radio" name="" id="">
            </div>
        </section>
        <footer>
            <div>FOOTER 1</div>
            <div>FOOTER 2</div>
            <div>FOOTER 3</div>
        </footer>
    </main>
</body>
<script>
    let modalLinks = document.querySelectorAll('a[data-modal]');
    modalLinks.forEach(link => 
        link.addEventListener('click', function() {
            openModal(link)
        })
    );

    function openModal(e) {
        const el = e.closest('.card');
        const modal = el.querySelector('[modal]');
        modal.setAttribute('modal', 'active');
    }
    function closeModal(e) {
        const modal = e.closest('[modal]');
        modal.setAttribute('modal', '');
    }
</script>
</html>

  • Related