GVKun编程网logo

如何在 html/css 中使文本响应?(css用于设置html页面中的文本内容)

2

在这篇文章中,我们将为您详细介绍如何在html/css中使文本响应?的内容,并且讨论关于css用于设置html页面中的文本内容的相关问题。此外,我们还会涉及一些关于ASP.NETMVC中@Html.P

在这篇文章中,我们将为您详细介绍如何在 html/css 中使文本响应?的内容,并且讨论关于css用于设置html页面中的文本内容的相关问题。此外,我们还会涉及一些关于ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处、asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)的知识,以帮助您更全面地了解这个主题。

本文目录一览:

如何在 html/css 中使文本响应?(css用于设置html页面中的文本内容)

如何在 html/css 中使文本响应?(css用于设置html页面中的文本内容)

如何解决如何在 html/css 中使文本响应?

我想让一个文本响应,它应该根据设备宽度相应地改变它的大小。

代码:

  1. .aligned {
  2. display: flex;
  3. align-items: top;
  4. }
  5. .p{
  6. padding: 15px;
  7. }
  8. img{
  9. border: 5px solid #555;
  10. }
  11. blockquote {
  12. font-family: Georgia,serif;
  13. font-size: 18px;
  14. font-style: italic;
  15. width: 800px;
  16. margin: 0.25em 0;
  17. padding: 0.35em 40px;
  18. line-height: 1.45;
  19. position: relative;
  20. color: #383838;
  21. }
  22. blockquote:before {
  23. display: block;
  24. padding-left: 10px;
  25. content: "\\201C";
  26. font-size: 80px;
  27. position: absolute;
  28. left: -20px;
  29. top: -20px;
  30. color: #7a7a7a;
  31. }
  32. blockquote cite {
  33. color: #999999;
  34. font-size: 14px;
  35. display: block;
  36. margin-top: 5px;
  37. }
  38. blockquote cite:before {
  39. content: "\\2014 \\2009";
  40. }
  1. <section>
  2. <link rel="stylesheet" href="assets/img/profile.jpg">
  3. <img src="assets/img/profile.jpg" align="left" width="370" height="500">
  4. <!-- <div/tag/dis/" target="_blank">display:inline-block;"> to put text under something or start new -->
  5. <div class="aligned">
  6. <div class="p">
  7. <p>I am currently exploring different options that will allow me to combine my interests in Business and Technology,and pursue a combined-degree in those fields. Motivated by my love for numbers,I started to explore the many ways I can use my Mathematical kNowledge and implement it into different areas. While I always had a passion for business,I was introduced to Computer Science in my junior years of high school,and I came to kNow that I was genuinely passionated about learning it. It offers a holistic approach to solve problems which I admire,and since then,I have transformed my interest into a personal hobby!</p>
  8. <p>I would always like to challenge myself and learn new programming langauges to increase the size of my toolBox. I was inspired by one of my friends to take my programming skills and put it into a good use; thus,I was introduced to competitive programming and large coding events such as hackathons!</p>
  9. <p>The intellectual challenges,creativity,and logic programming offers has always further strengthened the inevitable bond between us. All you need is a notepad,and the world becomes your <i>canvas.</i></p>
  10. <p>Challenging myself allows me to not only grow outside my comfort zone,but gives a new perspective towards life,and how there are no limitations/boundaries that halt you from growing! It is everlasting. Once you develop the growth mindset,your journey just never comes to a complete stop! You are able to focus on self-development and different ways to come out of the comfort zone.</p>
  11. <blockquote>
  12. nothing Is Impossible. The Word Itself Says ''IM Possible''
  13. <cite>Audrey Hepburn</cite>
  14. </blockquote>
  15. </div>
  16. </section><!-- End About Section -->

所以我想让文本和块引用(出现在底部)响应,它应该根据设备的宽度改变大小。

在移动设备上,我希望所有内容都在图像之后垂直对齐,但在较大的设备上,它应该看起来像我发送的代码输出中的内容。

这是我被用户建议的,但似乎不起作用:

  1. @media screen and (max-width: 250px) {
  2. font-size: 10vh; // Or the unit you want
  3. flex-direction: column;
  4. }

基本上,我希望文本在移动设备上垂直显示在图片下方,但在大型设备上,它应该显示我在上面的代码中发送的内容。

更新

这是我的输出:

我不想图片变小,不知道为什么修改后变小了,文字应该就在它下面。

解决方法

首先,从 HTML 中的 img 标签中删除 align="left"。 然后添加 float: left;到 CSS 中的 img 规则集。 最后,修改您的媒体查询以包含 section 和 img 选择器:

  1. .aligned {
  2. display: flex;
  3. align-items: top;
  4. }
  5. .p{
  6. padding: 15px;
  7. }
  8. img{
  9. border: 5px solid #555;
  10. float:left;
  11. }
  12. blockquote {
  13. font-family: Georgia,serif;
  14. font-size: 18px;
  15. font-style: italic;
  16. width: 800px;
  17. margin: 0.25em 0;
  18. padding: 0.35em 40px;
  19. line-height: 1.45;
  20. position: relative;
  21. color: #383838;
  22. }
  23. blockquote:before {
  24. display: block;
  25. padding-left: 10px;
  26. content: "\\201C";
  27. font-size: 80px;
  28. position: absolute;
  29. left: -20px;
  30. top: -20px;
  31. color: #7a7a7a;
  32. }
  33. blockquote cite {
  34. color: #999999;
  35. font-size: 14px;
  36. display: block;
  37. margin-top: 5px;
  38. }
  39. blockquote cite:before {
  40. content: "\\2014 \\2009";
  41. }
  42. @media screen and (max-width: 250px) {
  43. img{
  44. display: block;
  45. float: none;
  46. }
  47. section{
  48. font-size: 10vh; // Or the unit you want
  49. }
  50. }
  1. <section>
  2. <link rel="stylesheet" href="assets/img/profile.jpg">
  3. <img src="assets/img/profile.jpg" width="370" height="500">
  4. <!-- <div> to put text under something or start new -->
  5. <div class="aligned">
  6. <div class="p">
  7. <p>I am currently exploring different options that will allow me to combine my interests in Business and Technology,and pursue a combined-degree in those fields. Motivated by my love for numbers,I started to explore the many ways I can use my Mathematical knowledge and implement it into different areas. While I always had a passion for business,I was introduced to Computer Science in my junior years of high school,and I came to know that I was genuinely passionated about learning it. It offers a holistic approach to solve problems which I admire,and since then,I have transformed my interest into a personal hobby!</p>
  8. <p>I would always like to challenge myself and learn new programming langauges to increase the size of my toolbox. I was inspired by one of my friends to take my programming skills and put it into a good use; thus,I was introduced to competitive programming and large coding events such as hackathons!</p>
  9. <p>The intellectual challenges,creativity,and logic programming offers has always further strengthened the inevitable bond between us. All you need is a notepad,and the world becomes your <i>canvas.</i></p>
  10. <p>Challenging myself allows me to not only grow outside my comfort zone,but gives a new perspective towards life,and how there are no limitations/boundaries that halt you from growing! It is everlasting. Once you develop the growth mindset,your journey just never comes to a complete stop! You are able to focus on self-development and different ways to come out of the comfort zone.</p>
  11. <blockquote>
  12. Nothing Is Impossible. The Word Itself Says ''IM Possible''
  13. <cite>Audrey Hepburn</cite>
  14. </blockquote>
  15. </div>
  16. </section><!-- End About Section -->

,

首先,将您的 display: flex 放在您的部分,因为它将作为您的图像和文本的容器。

所以改变这个

  1. .aligned {
  2. display: flex;
  3. align-items: top;
  4. }

到这里

  1. section {
  2. display: flex;
  3. align-items: top;
  4. }

或者您可以将 .align 课程转移到部分

接下来,您的媒体查询语法错误且最大屏幕太小。即使是最小的屏幕(Iphone5s)也是 375px。在我看来,500px 是移动设备的安全最大宽度(只是我的偏好)。这是正确的代码

  1. @media screen and (max-width: 500px) {
  2. section {
  3. font-size: 10vh; // Or the unit you want
  4. flex-direction: column;
  5. }
  6. }

我忘了提及:要使 display: flex 工作,您需要将元素放在 div 中,以便 flex 可以按照您想要的方式对齐它。所以你要做的就是把你的图片放到这样的 div 中

  1. <div>
  2. <link rel="stylesheet" href="assets/img/profile.jpg">
  3. <img src="assets/img/profile.jpg" align="left" width="370" height="500">
  4. </div>

简而言之,您的 html 结构应如下所示

  1. <section>
  2. <div>
  3. place your image here
  4. </div>
  5. <div>
  6. place all your texts here
  7. </div>
  8. </section>

ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

1.Action、RenderAction加载办法的视图,履行Controller → Model → View的次序,然后把产生的页面带回到本来的View中再回传。而Partial、RenderPartial直接加载视图文件内容

2.Html.Partial可以直接供给用户控件名作为参数,而Html.Action须要有对应的Action,在Action内部返回PartailResult(即retun PartialView())。

3.对于简单的没有任何逻辑的用户控件,推荐应用Html.Partial;对于须要设置一些Model的用户控件,推荐应用Html.Action。当然,有Model数据也是可以应用Html.Partial办法的,可以看办法的重载。

4.Html.Partial与Html.Action有啥区别呢?区别就是,Html.Partial只有一个视图,而Html.Action除了视图,还真的有个Action跟它对应,所以,Html.Action功能比Html.Partial要强。

 

如何调用这个Html.Partial

 //1、以视图名使用当前文件夹下的视图(如果没有找到,则搜索 Shared 文件夹)
@Html.Partial( "_test" //加载对应文件 /Views/Product/_test.cshtml
 
//2、依据应用根路径定位视图// 以 "/" 或 "~/" 开头的路径代表应用根路径
@Html.Partial( "~/Views/Product/_test.cshtml" )
@Html.Partial( "/Views/Product/_test2.cshtml" )
 
//3、加载其他目录的 视图文件
//注意:需要复制views中的web.config 到template目录,否则会提示  "/template/A.cshtml”处的视图必须派生自 WebViewPage 或 WebViewPage<TModel>"
@Html.Partial( "/template/A.cshtml" )

asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处

asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处

在ASP.NET MVC中,有什么区别:

Html.Partial and Html.RenderPartial
Html.Action and Html.RenderAction

解决方法

Html.Action调用控制器的动作,这意味着它实例化控制器实体,调用动作方法,构建模型并返回视图结果.

Html.Partial使用已创建的模型(或者可以在没有模型的情况下调用)来渲染指定的视图.

何时使用一个而不是另一个?如果您已有模型并且只想拥有可重复使用的视图,请选择Html.Partial.如果你看到某个部分值得拥有自己的模型和动作,那么使用Html.Action可能是有意义的.

这个问题在this article中有更详细的讨论,你在上面看到的基本上是它的摘录.

asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

1、带有Render的方法返回值是void,在方法内部进行输出;不带的返回值类型为MvcHtmlString,所以只能这样使用:

     @Html.Partial 对应 @{Html.RenderPartial(....);}@Html.Action 对应 @{Html.RenderAction(....);}

2、Html.Partial可以直接提供用户控件名作为参数,

    而Html.Action需要有对应的Action,在Action内部返回PartailResult(即retun PartialView())。

3、对于简单的没有任何逻辑的用户控件,推荐使用Html.Partial;对于需要设置一些Model的用户控件,推荐使用Html.Action。当然,有         Model数据也是可以使用Html.Partial方法的,可以看方法的重载。

4、使用Html.Action有个好处,就是可以根据不同的场景选择不同的用户控件。比如:@Html.Action("UserInfoControl")在对应的    UserInfoControl这个Action中,在用户未登录的时候,可以retun PartialView("LogOnUserControl");登录后,可以retun  PartialView("UserInfoControl");

CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)

CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)

最近简单 HTML 

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Hello!</title>
    </head>
    <body>
        Hello, world!
    </body>
<html>

HTML 中 form 表单

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Forms</title>
</head>
<body>
    <form>
        <input type="text" placeholder="First Name" name="first">
        <input type="password" placeholder="Password" name="password">
        <div>
            Favorite Color:
            <input name="color" type="radio" value="blue"> Blue
            <input name="color" type="radio" value="green"> Green
            <input name="color" type="radio" value="yellow"> Yellow
            <input name="color" type="radio" value="red"> Red

        </div>
        <input type="submit">
    </form>
</body>
</html>

相对比较复杂的 HTML

超链接 href

有序列表和无序列表

图片

表格

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>HTML Elements</title>
    </head>
    <body>
        <!-- We can create headings using h1 through h6 as tags. -->
        <h1>A Large Heading</h1>
        <h2>A Smaller Heading</h2>
        <h6>The Smallest Heading</h6>

        <!-- The strong and i tags give us bold and italics respectively. -->
        A <strong>bold</strong> word and an <i>italicized</i> word!

        <!-- We can link to another page (such as cs50''s page) using a. -->
        View the <a href="https://cs50.harvard.edu/">CS50 Website</a>!

        <!-- We used ul for an unordered list and ol for an ordered one. both ordered and unordered lists contain li, or list items. -->
        An unordered list:
        <ul>
            <li>foo</li>
            <li>bar</li>
            <li>baz</li>
        </ul>
        An ordered list:
        <ol>
            <li>foo</li>
            <li>bar</li>
            <li>baz</li>
        </ol>

        <!-- Images require a src attribute, which can be either the path to a file on your computer or the link to an image online. It also includes an alt attribute, which gives a description in case the image can''t be loaded. -->
        An image:
        <img src="../../images/duck.jpeg" alt="Rubber Duck Picture">
        <!-- We can also see above that for some elements that don''t contain other ones, closing tags are not necessary. -->

        <!-- Here, we use a br tag to add white space to the page. -->
        <br/> <br/>

        <!-- A few different tags are necessary to create a table. -->
        <table>
            <thead>
                <th>Ocean</th>
                <th>Average Depth</th>
                <th>Maximum Depth</th>
            </thead>
            <tbody>
                <tr>
                    <td>Pacific</td>
                    <td>4280 m</td>
                    <td>10911 m</td>
                </tr>
                <tr>
                    <td>Atlantic</td>
                    <td>3646 m</td>
                    <td>8486 m</td>
                </tr>
            </tbody>
        </table>
    </body>
<html>

 CSS 简介

在 HTML 中嵌入 CSS

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Hello!</title>
    </head>
    <body>
        <h1 style="color: blue; text-align: center;">A Colorful Heading!</h1>
        Hello, world!
    </body>
<html>

指定整个 body 的样式

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Hello!</title>
    </head>
    <body style="color: blue; text-align: center;">
        <h1 >A Colorful Heading!</h1>
        Hello, world!
    </body>
<html>

将 CSS 放在前面

 <html lang="en">
  <!DOCTYPE html>
  <head>
      <title>Hello!</title>
      <style>
          h1 {
              color: blue;
              text-align: center;
          }
      </style>
  </head>
  <body>
      <h1 >A Colorful Heading!</h1>
      Hello, world!
  </body>
  </html>

单独的 CSS 文件

 h1 {
      color: blue;
      text-align: center;
  }
<html lang="en">
  <!DOCTYPE html>
  <head>
      <title>Hello!</title>
      <link rel="stylesheet" href="styles.css">
  </head>
  <body>
      <h1 >A Colorful Heading!</h1>
      Hello, world!
  </body>
  </html>

给表格添加 CSS

table {
    border: 1px solid black;
    border-collapse: collapse;
}

td {
    border: 1px solid black;
    padding: 2px;
}

th {
    border: 1px solid black;
    padding: 2px;
}
table {
    border: 1px solid black;
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 2px;
}

更复杂的 CSS
 

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Pseudoclasses</title>
        <style>
            button {
                background-color: red;
                width: 200px;
                height: 50px;
                font-size: 24px;
            }

            button:hover {
                background-color: green;
            }
        </style>
    </head>
    <body>
        <button>Button 1</button>
        <button>Button 2</button>
        <button>Button 3</button>

    </body>
<html>

 

今天关于如何在 html/css 中使文本响应?css用于设置html页面中的文本内容的讲解已经结束,谢谢您的阅读,如果想了解更多关于ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处、asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)的相关知识,请在本站搜索。

本文标签:

上一篇通过 CSS 更改 ioslides 中的项目符号类型(css项目符号怎么加颜色)

下一篇如何在没有 CSS 的情况下更改列标题的字体(没有css样式)