【问题标题】:How to increase the width of my twitter feed如何增加我的推特提要的宽度
【发布时间】:2015-12-19 00:44:33
【问题描述】:

我正在尝试增加网页上显示的 twitter 提要的宽度,我向其中添加了一个 Div id 并尝试在 css 中增加它的大小,但是它在某个点之后停止变大,我还想在其中添加图像我的投资组合部分包括 3 张随机图片,当您在 CSS 中将鼠标悬停在它们上方时,它们会变大并改变大小,我该怎么做?另外我不知道如何更改网页背景的颜色,我尝试过的一切都不起作用。谢谢。

我为下面的代码提供了 HTML、CSS 和 JS 代码。

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Muhammed's Webpage</title>

    <style>
        #body {
            margin: auto;
            max-width: 85%;
            font-family: 'Exo 2', Times, serif;
            color: black;
            padding-top: 50px;
        }

        .mainlogo {
            font-size: 18px;
            font-weight: 900;
            font-family: 'Montserrat', Times, serif;
            text-decoration: underline;
        }

        nav {
            position: fixed;
            top: 0;
            width: 100%;
            margin-left: 4%;
            opacity: 0.8;
            max-width: 85%;

        }

        ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: white;
            position: fixed;
            font-size: 20px;
        }

        li {
            float: left;
            border-right: 2px solid black;
        }

        li:first-child {
            border-left: 2px solid black;
        }

        li a {
            display: inline-block;
            color: black;
            text-align: justify;
            padding: 36px 40px;
            text-decoration: underline;
            font-family: 'Montserrat', Times, serif;
            text-shadow: 4px 4px 4px #aaa;
        }

        li a:hover {
            background-color: #C2E5E5;
            color: black;
        }

        .yt {
            margin-left: 53px;
            margin-top: 30px;
            display: inline-block;
            height: 500px;
            width: 650px;
        }

        #twitter {
            display: inline-block;
            height: 300px;
            width: 300px;
        }

        .contentbox {
            font-family: 'Exo 2', sans-serif;
            font-weight: 700;
            font-size: 2em;
            padding-left: 10px;
            padding-bottom: 0;
            margin-bottom: 0;
            background-color: #C2E5E5;
        }

        .content {
            background-color: #C2E5E5;
        }

        p {
            text-indent: 3%;
            margin: auto;
            max-width: 95%;
        }

        .contentbox {
            font-family: 'Montserrat', Times, serif;
            font-size: 28px;
        }
    </style>
    <script>
        !function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
            if (!d.getElementById(id)) {
                js = d.createElement(s);
                js.id = id;
                js.src = p + "://platform.twitter.com/widgets.js";
                fjs.parentNode.insertBefore(js, fjs);
            }
        }(document, "script", "twitter-wjs");
    </script>
</head>
<body>
<div class="mainlogo">

    <div>Muhammed's
        <br>Webpage
    </div>

</div>

<div id="body">

    <nav>
        <ul>

            <li><a href="#BasicInfo"> BASIC INFORMATION </a></li>
            <li><a href="#CurriculumVitae"> CURRICULUM VITAE </a></li>
            <li><a href="#Portfolio"> PORTFOLIO </a></li>
            <li><a href="#Report"> REPORT </a></li>
        </ul>
    </nav>

    <div class="yt">
        <iframe src="http://www.youtube.com/embed/nKIu9yen5nc">
        </iframe>
    </div>

    <div id="twitter">
        <a class="twitter-timeline" href="https://twitter.com/applenws" data-widget-id="674678491141570560">Tweets by
            @applenws</a>
    </div>

    <div class="content" id="Basic Information">
        <h3 class="contentbox"><u>Basic Information</u></h3>
        <p>
            <br>Name: Muhammed Hussain
            <br>Age: 18
            <br>Contact Number: 07711909673
            <br>E-mail: Mhuss055@gold.ac.uk
            <br>Occupation: Student of Goldsmiths, University of London
            <br>Hobbies & Interests: Playing on my ps4 and outdoor tennis
            <br>
            <br>
        </p>
    </div>

    <div class="content" id="Curriculum Vitae">
        <h3 class="contentbox"><u>Curriculum Vitae</u></h3>
        <p>
            <br><u>Jun 2015 - Currently Employed</u> : <b>Harrods - Operations Assistant</b>
            <br>Responsible for ensuring all daily administrative tasks are met within time schedule
            <br>Worked with colleagues to sustain a world class service of luxury goods, through providing an excellent
            service while working in a team environment and focusing on customer service
            <br>Proactive use of CCA and SAP software on a regular basis, in order to deal with online orders.
            <br>
            <br><u>Jun 2014 - Sep 2014</u> : <b>Direct Accountancy - Accounts Assistant</b>
            <br>Assisted Account Manager through creating invoices and sending to customers using SAGE software
            <br>Made and arranged invoices occasionally for customers, and ensured these were sent out promptly upon
            receiving the order.
            <br>
            <br>
            <u>Skills Gained:</u>
            <br>Communication - Established rapport and resolved queries within pressurised customer service
            environments
            <br>Teamwork - Motivated and developed colleagues to work effectively
            <br>Leadership - Showed leadership qualities when delivering end of unit presentations at Sixth form
            <br>
            <br>
        <p>
    </div>

    <div class="content" id="Portfolio">
        <h3 class="contentbox"><u>Portfolio</u></h3>
        <p>
            <br>Here im going to include some images and use css to make them interactive and exciting
            <br>
            <br>
        </p>
    </div>


    <div class="content" id="Report">
        <h3 class="contentbox"><u>Report</u></h3>
        <p>
            <br>Here im going to state why i did what i did in detail
        <p>
            <br>
    </div>

    <br>
    <br>
</div>

</body>
</html>

【问题讨论】:

    标签: javascript html css


    【解决方案1】:
    1. 您的 Twitter 提要在 HTML 属性中设置了宽度。擦除该属性并将其移至 CSS。这应该可以解决 Twitter 的问题。 编辑:记住高度设置在Twitter &gt; Settings &gt; Widget &gt; Height

    - 编辑 1 -

    现在我知道你的 Twitter 提要不能由你控制,你必须控制你的 Twitter 脚本的结果,默认情况下通常是 600px 的高度。不管这是什么,你知道它最终会使用twitter-timeline CSS 类来设置 iframe 的样式,所以你只需要像这样覆盖这个值:

    .twitter-timeline {
        height: 503px; // 503 because for some reason it needs 3 more pixels to catch up with your video, as I could see.
    }
    

    - 结束编辑 1 -

    1. 您刚刚将您的所有个人信息泄露给了网络上的陌生人。如果它们属实,您可能会在几秒钟内收到垃圾邮件。我建议您提供必要的代码。有很多与问题无关的CSS和HTML,您可以在另一个问题中简单地询问它们或将它们分开解释。

    2. 要放置图片,您可以做很多事情,随机图片意味着 JavaScript 或预加载 PHP。我想你会从你的站点加载它们,比如说/images/computers/ 并给它们一个类,例如photo。然后在 CSS 上,您可以执行以下操作:

      .photo {
          height:200px;
      }
      .photo:hover {
          height:400px;
      }
      

    这将使它在使用 CSS 悬停时变得更大。如果您想对其进行动画处理,您可能需要使用其他 CSS 属性。在网络上搜索,您会找到它们。

    - 编辑 2 -

    因此,查看您的带有 photo 类的图片,我发现您没有正确添加 % 值。您需要为每张图像找到一个平衡值。在您的情况下,我们基本上正在使用图像paddingmarginwidth。所以有 3 张图片,你知道百分比必须达到 100% 左右:

    .photo {
        background-color: white;
        padding: 1%;
        margin-left: 5%;
        margin-bottom: 2%;
        -webkit-box-shadow: 0 0 0.2em 0.15em rgba(00, 00, 00, 0.35);
        box-shadow: 0 0 0.2em 0.15em rgba(00, 00, 00, 0.35);
        float: left;
        width: 25%;
        transition: all 0.25s ease-out;
    }
    

    根据我给你写的这段代码,现在公式是:

    (3 * 25%) + (6 * 1%) + (3 * 5%) = 75% + 6% + 15% = 96%

    6 乘以 1%,因为内边距将添加到图片的左右两侧。

    - 结束编辑 2 -

    1. 网站的背景颜色?那太基础了。这取决于您的需要,您可以将背景颜色设置为&lt;html&gt;&lt;body&gt;。我将使用 HTML:

       html {
           background-color:red;
       }
      

    这样,您的网站将具有红色背景。当然,您可以使用 HEX、rgb() 或 rgba() 或颜色名称,随心所欲。

    【讨论】:

    • 感谢您的建议,除了当我尝试在 css 中为我的 twitter 提要定义 height 和 width 属性时,它现在无论我做得多小都不会降低高度,现在这是 twitter 提要的 css 代码:#twitter { display:inline-block;高度:300px;宽度:400px; }
    • @m.hussain 简单! Twitter 提要(称其为小部件)的高度在 Twitter 上设置!您需要转到“设置”>“小部件”并在此处更改高度!
    • 对不起,我很困惑,如果我在 css 中定义它的大小,我会认为小部件应该改变大小,但它的高度现在没有减少,那么我该如何减少它?
    • @m.hussain 好的。所以我也不喜欢 Twitter 的做法,但就是这样。如果你真的想覆盖任何 Twitter 使你的小部件高度成为的东西,你需要在你的 CSS 高度之后添加!important。我的意思是这样; #twitter { height: 300px !important; }。试试看。但正确的方法应该是访问 Twitter 的网站并更改小部件编辑器的高度。
    • 更改主体的宽度对我有帮助,因为我能够使小部件更宽,因此现在看起来更好一些,但即便如此我也无法将小部件的高度更改为 500px,这就是我希望它是。我现在尝试过 inline 和 inline-block 。另外我如何在视频和小部件之间创建一些空间,比如 3-4 厘米就足够了。顺便谢谢
    【解决方案2】:

    试试这个代码。

    具有 max-width="520" 的 Twitter 框架是一个边界.portfolia 图像也支持响应式。

    让它酷,我们喜欢我们的编码。

    <!DOCTYPE html>
    <html lang="en">
    
     <head>
      <title>Muhammed's Webpage</title>
    
      <link rel="stylesheet" type="text/css" href="homepage.css">
      <script src="homepage.js"></script>
    
      <link href='https://fonts.googleapis.com/css?family=Exo+2:500,700,800italic,600|Montserrat' rel='stylesheet' type='text/css'>
    
     </head>
    
     <div class="mainlogo">
    
      <body>Muhammed's 
       <br>Webpage</body>
    
      </div>
    
       <div id="body">
    
        <nav>
          <ul>
    
            <li><a href="#BasicInfo"> BASIC INFORMATION </a></li>
            <li><a href="#CurriculumVitae"> CURRICULUM VITAE </a></li>
            <li><a href="#Portfolio"> PORTFOLIO </a></li>
            <li><a href="#Report"> REPORT </a></li>
          </ul>
        </nav>
    
        <div class="yt">
          <iframe  src="http://www.youtube.com/embed/nKIu9yen5nc">
          </iframe>
        </div>
    
       <div id = "twitter">
        <a class="twitter-timeline" href="https://twitter.com/applenws" data-widget-id="674678491141570560">Tweets by @applenws</a>
       </div>
    
        <div class="content" id="Basic Information">
          <h3 class="contentbox"> <u>Basic Information</u> </h3>
          <p>
            <br>Name: Muhammed Hussain 
            <br>Age: 18 
            <br>Contact Number: 07711909673
            <br>E-mail: Mhuss055@gold.ac.uk
            <br>Occupation: Student of Goldsmiths, University of London
            <br>Hobbies & Interests: Playing on my ps4 and outdoor tennis
            <br>
            <br>  
          </p>
        </div>
    
        <div class="content" id="Curriculum Vitae">
          <h3 class="contentbox"> <u>Curriculum Vitae</u> </h3>
          <p>
            <br><u>Jun 2015 - Currently Employed</u> : <b>Harrods - Operations Assistant</b> 
            <br>Responsible for ensuring all daily administrative tasks are met within time schedule
            <br>Worked with colleagues to sustain a world class service of luxury goods, through providing an excellent service while working in a team environment and focusing on customer service
            <br>Proactive use of CCA and SAP software on a regular basis, in order to deal with online orders.
            <br>
            <br><u>Jun 2014 - Sep 2014</u> : <b>Direct Accountancy - Accounts Assistant</b>
            <br>Assisted Account Manager through creating invoices and sending to customers using SAGE software
            <br>Made and arranged invoices occasionally for customers, and ensured these were sent out promptly upon receiving the order.
            <br>
            <br>
            <u>Skills Gained:</u>
            <br>Communication - Established rapport and resolved queries within pressurised customer service environments
            <br>Teamwork - Motivated and developed colleagues to work effectively
            <br>Leadership - Showed leadership qualities when delivering end of unit presentations at Sixth form 
            <br>
            <br> 
          <p>
        </div>
    
        <div class="content" id="Portfolio" style="height:250px">
          <h3 class="contentbox"> <u>Portfolio</u> </h3>
          <p>
            <br>Here im going to include some images and use css to make them interactive and exciting
            <br>
            <br>
          </p>
    
          <ul class="portfolioimg" style="">
             <li><img src="https://getbootstrap.com/assets/img/devices.png" alt="Responsive across devices" class="img-responsive"></li>
             <li><img src="https://getbootstrap.com/assets/img/devices.png" alt="Responsive across devices" class="img-responsive"></li>
             <li><img src="https://getbootstrap.com/assets/img/devices.png" alt="Responsive across devices" class="img-responsive"></li>
    
          </ul>
    
        </div>
    
    
        <div class="content" id="Report">
          <h3 class="contentbox"> <u>Report</u> </h3>
          <p>
            <br>Here im going to state why i did what i did in detail
          <p>
            <br>
        </div>
    
            <br>
            <br>
    
      </body>
    
    </html>
    
    
    <style>
    body{
      background-color:gray;
    }
    
    
    .portfolioimg {
        clear: both;
        display: block;
         margin: 30px auto 0;
        padding: 0;
        position: static !important;
        text-align: center;
        width: 1000px;
        background-color:transparent;
    }
    .portfolioimg > li {
        background-color: transparent !important;
        border: medium none !important;
        display: inline-block;
        float: none;
        list-style-type: none;
        margin-right: 40px;
        text-align: center;
    }
    .portfolioimg > li img{
      width:200px;
      }
    
    #body {
    
    
        margin: auto;
        max-width: 85%; 
        font-family: 'Exo 2', Times, serif;
        color: black;
        padding-top: 50px;
    }
    
    .mainlogo {
        font-size: 18px;
        font-weight: 900;
        font-family: 'Montserrat' , Times, serif;
        text-decoration: underline;
    }
    nav {
        position: fixed; 
        top: 0;  
        width: 100%;
        margin-left: 4%;
        opacity: 0.8;
        max-width: 85%;
    
    }
    ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
        background-color: white;
        position: fixed;
        font-size: 20px;
    }
    li {
        float: left;
        border-right: 2px solid black;
    }
    
    li:first-child {
        border-left: 2px solid black;
    }
    li a {
        display: inline-block;
        color: black;
        text-align: justify;
        padding: 36px 40px; 
        text-decoration: underline; 
        font-family: 'Montserrat', Times, serif;
        text-shadow: 4px 4px 4px #aaa ;
    }
    li a:hover {
        background-color: #C2E5E5;
        color: black; 
    }
    
    .yt {
      margin-left: 53px;
      margin-top: 30px;
      display:inline-block;
      height: 500px;
      width: 650px;
    } 
    
    #twitter {
      display:inline-block;
      height: 300px;
      width: 520px;
    }
    
    .contentbox {
        font-family: 'Exo 2', sans-serif;
        font-weight: 700;
        font-size: 2em;
        padding-left: 10px;
        padding-bottom: 0;
        margin-bottom: 0;
        background-color:  #C2E5E5;
    }
    .content {
        background-color: #C2E5E5;
    }
    p {
        text-indent: 3%; 
        margin: auto;
        max-width: 95%;
    }
    
    .contentbox {
        font-family: 'Montserrat', Times, serif;
        font-size: 28px;
    }
    </style>
    
    <script>
    !function(d,s,id){
        var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
        if(!d.getElementById(id)){
            js=d.createElement(s);
            js.id=id;
            js.src=p+"://platform.twitter.com/widgets.js";
            fjs.parentNode.insertBefore(js,fjs);
        }
    }(document,"script","twitter-wjs");
    </script>
    

    【讨论】:

    • 嘿伙计,感谢您的帮助。我只是尝试使用您的代码,但问题是当我使用该宽度时,它会低于视频并且我希望它在同一行上,即使我通过更改宽度使它们在同一行上,高度也不会再小一点,这是我用于高度和宽度的尺寸#twitter { display:inline-block;高度:300px;宽度:400px; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多