html CSS

如何解决html CSS

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Site de Yani Mira</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <div id = "banniere">
            <img src="/images/banniere_site.png" alt="">
        </div>
        <div class="dropdown">
            <button class="dropbtn">Menu^</button>
            <div class="dropdown-content">
               <a href="#">Accueil</a>
               <a href="#">Telecharger CV</a>
               <a href="#">Chaîne Youtube</a>
               <a href="#">Contact</a>
               <a href="#">Mes projets</a> 
            </div>            
        </div>
         <div id='bienvenue'>Bienvenue sur mon Site</div>
         <div id="banniere">
         <img src="images/banniere_site.png" alt="">
        </div>
        <section>
            <div id="presentation">
                Je me présente je m'appelle Yani Mira
            </div>
    <div id="texte_section">Je suis un jeune développeur en 3ème année à l'école d"informatique
        ESTIAM (Paris 20) et suis en contrat d'alternance avec la société
        de consulting informatique Xenoo.
        Depuis petit je suis passioné par les nouvelles technologies et
        souhaite en faire mon métier.</div>
        <img class="photodemoi" src="images/yani_photo_resized.jpg" alt="">
        </section>
        <script src="" async defer></script>
    </body>
</html>
@font-face {
    font-family: 'freshmannormal';
    src: url('polices/freshman/freshman-webfont.woff2') format('woff2'),url('polices/freshman/freshman-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}
@font-face {
    font-family: 'gowaitalic';
    src: url('gowa-italic-webfont.woff2') format('woff2'),url('gowa-italic-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}




@font-face {
    font-family: 'gowaregular';
    src: url('polices/gowa/gowa-regular-webfont.woff2') format('woff2'),url('polices/gowa/gowa-regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}



#bienvenue{
    font-family: 'freshmannormal';
    text-align: center;
    border-width: 100%;
    border-style: solid;
    border-radius: 40px;
    border-left: 40px;
    border-right: 40px;
     height: 100px; 
     height: auto;
    width: 100%;
    font-size: 3em;
    background-color: antiquewhite;
    margin-right: 20em;    
}


#banniere img
{
    width: 100%;
    border-radius: 30px;
    display: flex;
    /* margin-left: 25%; */
}

#presentation{
    font-family: 'gowaregular';
    font-weight: bold;
    font-size: 2em;

}
#text_section{
}
section{
    font-family:sans-serif;
    padding-right: 10em;
    margin-right: 40px;
    margin-left: 40px;
    padding-bottom: 100px;
    font-size: 2em ;
    border: 10px;
    border-radius: 40px;
    border-style: solid ;
    border-color:antiquewhite;
    text-align: center;
}

.photodemoi{
    border-style: solid;
    border-color: antiquewhite;
    height: 7em;
    width: 6em;
    position: relative;
    bottom: 160px;
    left:8.5em; 
    float: right;
    border-radius: 20px;
}

/* Le bouton du dropdown*/
.dropbtn {
    font-family: 'freshmannormal';
    background-color: antiquewhite;
    color: black;
    padding: 16px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    float: right;
    margin-right: 40px;
    margin-top: 1px;
  }
  
/* Configuration du container dropdown */

  /* Contenu du dropdown (qu'on a caché avec display:none) */
  .dropdown-content{
      display: none;
      position: absolute;
      background-color: #f9f9f9;
      min-width: 160px;
      box-shadow: 0px 8px 16px 0px rgba(0,0.2);
      padding: 12px 16px;
      /* margin-left: 110em; */
      z-index: 1;     
      
  }

  /* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }

  /* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: #ddd;
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
    background-color:antiquewhite;
}
@font-face {
    font-family: 'freshmannormal';
    src: url('polices/freshman/freshman-webfont.woff2') format('woff2'),0.2);
      padding: 12px 16px;
      /* margin-left: 110em; */
      z-index: 1;     
      
  }

  /* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }

  /* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: #ddd;
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
    background-color:antiquewhite;
}
@font-face {
    font-family: 'freshmannormal';
    src: url('polices/freshman/freshman-webfont.woff2') format('woff2'),0.2);
      padding: 12px 16px;
      /* margin-left: 110em; */
      z-index: 1;     
      
  }

  /* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }

  /* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: #ddd;
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
    background-color:antiquewhite;
}

大家好,我遇到了一个问题,我将下拉按钮放在页面的最右边(最初位于最左边),但是当我将鼠标悬停在下拉按钮上时,下拉内容显示在最左边尝试将其边距向左px移动,但是它起作用了,但问题是它没有响应,如果我缩小页面,则当我将鼠标悬停在下拉按钮上时,我不再看到下拉内容了。

这是我的CSS代码:

[在此处输入图片描述] [1]

我使用代码进行了编辑

编辑前: [在此处输入图片描述] [2]

在编辑https://i.stack.imgur.com/zv2od.png之前 编辑后:https://i.stack.imgur.com/tup88.png

解决方法

看到截图后,我可以判断出您的问题不是将dropbtn定义为内容的相对位置,而只是将内容定义为绝对位置,默认情况下会将其放在您身体的左上方。 为了解决它,尝试添加位置:relative;在您的dropbtn上 另一件事是,当您使用float时,必须在完成后清除它,我个人不喜欢使用float,而是可以将按钮定义为display:block;然后给它margin-left:auto;它将其放置在屏幕的右侧。

,

好的,我刚刚解决了这个问题,我只需要适当地放置.dropdown类,并放置一个相对于它的位置。 对那些不好的人表示抱歉,这是我第一次问堆栈溢出问题,并感谢您的帮助。

,

嘿,凯夫米再次找到以下代码供您考虑,并告诉我是否还需要其他

HTML

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Site de Yani Mira</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div id = "banniere">
        <img src="/images/banniere_site.png" alt="">
    </div>
    <div class="dropdown">
        <button class="dropbtn">Menu^</button>
        <div class="dropdown-content">
           <a href="#">Accueil</a>
           <a href="#">Telecharger CV</a>
           <a href="#">Chaîne Youtube</a>
           <a href="#">Contact</a>
           <a href="#">Mes projets</a> 
        </div>  

    </div>
     <div id='bienvenue'>Bienvenue sur mon Site</div>
     <div id="banniere">
     <img src="images/banniere_site.png" alt="">
    </div>
    <section>
        <div id="presentation">
            Je me présente je m'appelle Yani Mira
        </div>
<div id="texte_section">Je suis un jeune développeur en 3ème année à l'école d"informatique
    ESTIAM (Paris 20) et suis en contrat d'alternance avec la société
    de consulting informatique Xenoo.
    Depuis petit je suis passioné par les nouvelles technologies et
    souhaite en faire mon métier.</div>
    <img class="photodemoi" src="images/yani_photo_resized.jpg" alt="">
    </section>
    <script src="" async defer></script>
</body>
</html>

CSS

@font-face {
    font-family: 'freshmannormal';
    src: url('polices/freshman/freshman-webfont.woff2') format('woff2'),url('polices/freshman/freshman-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}
@font-face {
    font-family: 'gowaitalic';
    src: url('gowa-italic-webfont.woff2') format('woff2'),url('gowa-italic-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}




@font-face {
    font-family: 'gowaregular';
    src: url('polices/gowa/gowa-regular-webfont.woff2') format('woff2'),url('polices/gowa/gowa-regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;

}



#bienvenue{
    font-family: 'freshmannormal';
    text-align: center;
    border-width: 100%;
    border-style: solid;
    border-radius: 40px;
    border-left: 40px;
    border-right: 40px;
     height: 100px; 
     height: auto;
    width: 100%;
    font-size: 3em;
    background-color: antiquewhite;
    margin-right: 20em;
  position:absolute;
  top:1%;
  left:0;
  z-index:-1;
}


#banniere img
{
    width: 100%;
    border-radius: 30px;
    display: flex;
    /* margin-left: 25%; */
}

#presentation{
    font-family: 'gowaregular';
    font-weight: bold;
    font-size: 2em;

}
#text_section{
}
section{
    font-family:sans-serif;
    padding-right: 10em;
    margin-right: 40px;
    margin-left: 40px;
    padding-bottom: 100px;
    font-size: 2em ;
    border: 10px;
    border-radius: 40px;
    border-style: solid ;
    border-color:antiquewhite;
    text-align: center;
    margin-top:2rem;
}

.photodemoi{
    border-style: solid;
    border-color: antiquewhite;
    height: 7em;
    width: 6em;
    position: relative;
    bottom: 160px;
    left:8.5em; 
    float: right;
    border-radius: 20px;
}

.dropdown {
  position: relative;
}

/* Le bouton du dropdown*/
.dropbtn {
    display:block;
    font-family: 'freshmannormal';
    background-color: antiquewhite;
    color: black;
    padding: 16px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    margin-left:auto;
    margin-right:1rem;
    margin-top:.1rem;
  }
  
/* Configuration du container dropdown */

  /* Contenu du dropdown (qu'on a caché avec display:none) */
  .dropdown-content{
      opacity:0;
      position: absolute;
    top: 120%;
    width: 100%;
    height: 0;
      background-color: #f9f9f9;
/*       min-width: 160px; */
      box-shadow: 0px 8px 16px 0px rgba(0,0.2);
/*       padding: 12px 16px; */
      /* margin-left: 110em; */
      z-index: 1;     
      border-radius:30px;
    text-align:center;
    padding:1rem 0;
    transform: translateY(-100vh);
    transition: all .8s;
  }

  /* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }

  /* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: #ddd;
}

/* Show the dropdown menu on hover */
.dropdown:hover > .dropdown-content {
    opacity: 1;
    height: 400%; 
    transform: translateY(0);
}

/* Change the background color of the dropdown button when the dropdown 
 content is shown */
.dropdown:hover .dropbtn {
    background-color:antiquewhite;
}

在我的代码笔https://codepen.io/ahamdan/pen/bGeEZeg上检查一下,然后告诉我这是否是你想要的

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-